Have you tried using the ‘the_content’ filter?
Something like this should probably do the Job , note that i have not had the time to test this .
function my_prettyadd($content) {
global $post;
$pattern = "/(<a(?![^>]*?rel=['\"]prettyPhoto.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
$replacement="$1 rel="prettyPhoto[".$post->ID.']">';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter("the_content","my_prettyadd");
simple regex that will add a rel to all images on the website
Related Posts:
- Changing WooCommerce Display Price Based on User Role & Category [closed]
- Changing JPEG compression depending on image size
- How to add headers to outgoing email?
- LESS CSS enqueue_style with add_filter to change rel attribute
- Remove Editor From Homepage
- Remove description from on Home
- What do add_filters() and apply_filter() do?
- How can I detect if a user changes their password?
- What to use instead of the content_save_pre filter?
- Moving sharedaddy buttons (in Jetpack) to the top of a post?
- How can I customize the wp_list_categories
- How can I reliably and globally disable wptexturize?
- Add class to woocommerce checkout body based on filter [closed]
- changing variable through filters or action hooks
- filter the_title problem in nav
- Add classname to the_category() function?
- Filter the URL of next_posts_link & previous_posts_link
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- How to replace any occurence of Gravatars with a local placeholder image?
- Sensei LMS Hooks to Remove Content
- How to re-enable a filter after disabling with __return_false
- Ignore dots when searching in the media library?
- Exclude One Category and its Subcategories using WP_LIST_FILTER
- What’s the best way to split admin-only functionality in the theme’s functions.php file?
- Gutenberg disable the “block” tab in right sidebar
- Where is this inline CSS code [closed]
- When to use actions and when to use filters
- add_filter to ‘woocommerce_before_main_content’ [closed]
- Why won’t my preg_replace work with content_save_pre?
- Echoing Categories only if they’re a child of a given category
- How Does comment_author Filter Work?
- Add ‘data-text’ attribute to TagCloud HTML
- Why in archive page doesn´t show read more button with excerpt?
- Removal of Jetpack OG Tags from old blog site
- Adding a title prefix with the the_title filter
- Walker_Nav_Menu doesn’t work in wp_page_menu_args filter
- get_posts() and filters
- Don’t see add_filter result in the site front page
- How can I include an existing custom sitemaps listing in wp-sitemap.xml?
- Display Externally Retrieved Data within a Custom Template
- Can the wordpress color palettes by changed through Javascript?
- Filter on the_content doesn’t update the content being searched via register_rest_route
- Where to add_filter in theme functions.php?
- upload_files cap to not loggen in users – add_cap to not logged in users
- Cannot change the definition of AUTOMATIC_UPDATER_DISABLED
- How do I add a checkmark to my-sites save settings hook
- tag removed not using a filter
- Add Lightbox To WordPress Native Gallery
- WordPress Image update filter
- How to remove this filter?
- get_post() containing gallery is outputting an unmatched closing div at the end of the content
- Trouble using remove_filter to override function in parent theme
- Load Posts’ individual body content on index starting at char 200 of each post
- How do I hook my function to run only after submitting login form
- How to combine multiple body classes
- Prepending character(s) to a custom tag title?
- How to replace username with email address in users table
- Modify existing plugin function with add_filter
- include specific Pages to wp_list_pages with filter
- why require – does not load filter
- How can I filter tag_description()?
- Email Obfuscation: Is antispambot() Acceptable? [closed]
- What are the steps + prerequisites for using an add_filter?
- an action hook when a post reaches a certain number of views
- WordPress overwrites UNC
- Need to return shortcode text instead of the output
- Excluding posts by meta, and also keeping posts without the meta
- Change tags url to search different site
- How to optionally append components to the output of a gutenberg block?
- Dashboard filter based on custom fields URL response code
- How to add custom media library mime icons?
- Custom SQL query slows down when using multiple OR … LIKE … in posts_where filter
- get_post() with filters applied
- I want to add string array to this function to filter displayed option in drpodown [closed]
- Drop down filter sort posts by latest, last 7 days and monthly
- Function not returning correct value for found_posts filter
- Unable to defer loading of jquery
- Remove style tags from head
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- Override admin selected page layout
- how to develop a filter in wordpress to let the user filter the page content depends on the date (newest to oldest etc…)?
- Print only parent categories of post in custom RSS feed
- Login logout below menu bar
- Use add_filter inside another function
- Add HTML to the bottom of each post in a post list
- How to filter reading/visibility posts based on role?
- Admin view: filter posts by whether they have specific taxonomy attached
- Filter posts by categories ajax is showing all the posts
- URL to filter posts by post meta similar to shop/?product_cat=”painting”
- Incrementing content with extra text after save/publish
- What scope is $blog_url = get_bloginfo() inside a function
- How to use a TinyMCE filter?
- Unable to get WordPress’s apply_filters(‘site_url’) to return a https scheme
- Admin filter/error if post title is too long
- Adding an orderby filter, casting postmeta with multiple keys
- Identify admin/logout and more filters
- Sanitizing a custom query’s clauses
- How can I display wp_link_pages before a shortcode, if it is used, or display after content?
- How to create a list of terms who’s posts also have a predefined external term?
- Limit total tags in the_content