Make image popup in content article automatically
Domanda
i want to make a content plugin in Joomla, in which whenever i insert image it automatically converts into popup.
for this i will use Jcemediapopup, it uses class="jcemediapopup"
i now just simply wants, whenever user insert image in article, with the help of our plugin that <img src
line coverts into like this <img class="jcemediapopup" src=
so that all image become Popup.
Any help !
Soluzione
unless you want to write a plugin for this, you can do it in a template override, eg. to apply this to e content article:
- copy /components/com_content/views/article/tmpl/default.php to /templates/yourtemplate/html/com_content/article/default.php
- where the article content is echoed (around line 187), apply the following:
change
<?php echo $this->item->text; ?>
to something like
<?php echo preg_replace('/<img src="([^"]+)" ([^>]*)>/',
'<a href="\1"><img src="\1" class="jcemediapopup" \2></a>',$this->item->text); ?>
You might have to tweak the regexp if the images already contain a class-tag ...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow