When I first created my site, I automatically made sure that all images had no links (image_default_link_type = none). Now I’ve done Lightbox, so I need to make all the images in all the posts clickable.
I need to translate all the images in all posts from the view:
<img src="https://example.com/wp-content/uploads/2018/04/Apple-iPhone-6-0.jpg" alt="" width="1500" height="1000" />
at
<a href="https://example.com/wp-content/uploads/2018/04/Apple-iPhone-6-0.jpg"> <img src="https://example.com/wp-content/uploads/2018/04/Apple-iPhone-6-0.jpg" alt="" width="1500" height="1000" /> </a>
How can I do that?
There is a function:
add_filter ('the_content', 'del_image_link');
function del_image_link ($ content) {
? $ content =
? preg_replace (array ('{a [^>] *> <img}', '{/> </a>}'), array ('<img', '/>'), $ content);
? return $ content;
}
It works in reverse order, that is, it makes absolutely all images with links non-sticky. I need to achieve the opposite effect.
-
This reply was modified 6 years, 8 months ago by AppleStage.
-
This reply was modified 6 years, 8 months ago by AppleStage.
-
This reply was modified 6 years, 8 months ago by AppleStage.
-
This reply was modified 6 years, 8 months ago by AppleStage.
-
This reply was modified 6 years, 8 months ago by AppleStage.