Hello everybody,
I would like to know if there is a way to take the first picture included in content area of a resource without using TV. is possible?
thx
"Destiny is not a matter of chance, it's a matter of choice"
-
☆ A M B ☆
- 24,524 Posts
You could make a plugin to parse the $modx->documentObject['content'] and pull out the first image tags, using a regular expression or a couple of PHP functions.
http://w-shadow.com/blog/2009/10/20/how-to-extract-html-tags-and-their-attributes-with-php/
Put it in a placeholder using the setPlaceholder API function
$modx->setPlaceholder('myImageTag', $img-src);
and then you can use the placeholder wherever you want it.
[ed. note: sottwell last edited this post 15 years ago.]
Hi sottwell,
many thx for your reply.
I try but does not seem easy :-(
Fabry
"Destiny is not a matter of chance, it's a matter of choice"
-
☆ A M B ☆
- 24,524 Posts
My advice would be to use an image TV, even if the same image is inserted at random points in the content.