On the contrary…
I’ve ran up into it on one of client’s site. Where, when I wanted to apply your plugin’s JS functionality, I had to actually use a PHP function to filter the custom content – slb_activate()
.
Anyway, you did not provide ANY valid reason why
- Your JS does not bind on any CSS class one could then easily and more efficiently use to bind your JS functionality.
- Why it wouldn’t work…
Let me show you a few examples on how to do it purely in JS (jQuery):
1. General $('a > img').parent()
will get you all image links, may be too hungry, you might want to provide option to set “content” class.
2. Every attachment image inserted into content (when not messed with in other way) has a class “wp-image-#” so $('a > img').filter('[class*="wp-image-"]').parent()
is more specific, same goes for wp-post-image and featured-image … Even images generated with wp_get_attachment_image()
have attachment-SIZECLASS
.
3. Add an option to provide a custom selector.
-
This reply was modified 7 years, 10 months ago by jave.web.