maybe use this regex:
$pattern = "/<a(.*?)href=('|\")([^>]*)('|\")(.*?)><img(.*?)src=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)class=('|\")([^>]*)('|\")(.*?)\/><\/a>/i";
function example_replace ($content) {
global $post;
$pattern = "/<a(.*?)href=('|\")([^>]*)('|\")(.*?)><img(.*?)src=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)class=('|\")([^>]*)('|\")(.*?)\/><\/a>/i";
$replacement="<a$1href=$2$3$4$5><img$6src=$7$8.$9$10$11class=$12$13 <strong>imagelink</strong>$14$15$16/><\/a>";
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
Related Posts:
- How to stop images from being wrapped in tags?
- Retrieve image from content, assign it as a featured, and then remove it from the content
- built-in responsive images in content – do I need to add anything to functions.php?
- Set padding for all content except images and few more elements
- How to get some information from the_content [closed]
- How to add a link to media file for every image inserted in content?
- Each custom image size in custom upload directory?
- How to automatically add rounded corners to thumbnails?
- Is there a simple way to just insert a link to an image (without inserting an image)?
- Watermarking Images with WordPress with WP_Image_Editor
- Get attachment/image info in JS
- Auto-modifying original [full size] images
- How to limit number of images being printer out in “Set Featured Image” pop up?
- Replace Woocommerce Images
- Change Output for Images in Content
- Crop image to horizontal or vertical by code based on image size
- Pasting images removes class attribute
- How can I make all gallery images to open in a new window?
- Open the attachment details modal
- Crop image without scaling or resizing with add_image_size()
- Can’t access ‘Store uploads in this folder’
- Is there a way to pull the first featured image in a loop and not all other featured images?
- How to Display Featured Image Title and ALT Attribute
- Is it possible to recover featured images after WordPress export/import
- how to stop generating different image sizes from parser
- Do I need to resize an image to fit the post?
- Add Small Image Size to Media Settings
- Batch process: remove first image from post content
- Link to large image version instead of original?
- Adding new size for Media screen in functions.php not working
- After installing ssl certificate images won’t show
- Random Size on Featured Image
- Some images not found 404 in localhost
- Images not showing on blog
- Why does Google Image Search still display my images?
- Dynamic tagged image galleries
- Image auto resize
- WP fails to upload files to media library, /wp-admin/async-upload.php 403 forbidden
- Add a background image for Custom Post Type archives page
- Images stopped loadding after adding SSl
- Background-image not showing? [closed]
- GoDaddy Number of Image Files Per Directory Exceeded
- Post and featured image have the same name, why is the attachment (image) is showing and not the post?
- Scaling an image in a WordPress post
- Setup Featured image on all posts from thesis thesis_post_image custom field?
- Ways to show multiple, separate galleries per post?
- Stop WordPress from cropping images using url parameters
- How to get the image-URL from Media-Upload in a post?
- How to get the Gallery form/section just like in Gutenberg block?
- Add clickable link on an image
- One of my image sizes isn’t showing up in srcset
- Conflict with single and double quotes
- How do I get a smaller size of an avatar image
- When the new post which has no image published, save the specific image as the featured image ( by category )
- download link for uploaded images for wordpress
- How do I link a featured photo to it’s post?
- Force default OG:Image – Yoast SEO [closed]
- Why do I have blury images in WordPress
- Disable save as image on smartphones using all browsers ( chrome, firefox, ie, cm, opera )
- How to get the title of the random images from media library?
- How to indent pictures on WordPress blog? [closed]
- How To Display Author Photo In WordPress without any plugin?
- Image and shortcode not showing in excerpt
- What is the plugin to import image from URL?
- Allow users to upload multiple images to their profile
- how to change format jpg to webp?
- User uploads image as “Featured Image” but WordPress resizes it?
- Hide Title tag on image Hover
- How to increase media image scale limit?
- Force WordPress to always generate a thumbnail for original image
- How to get the best resolution of image from srcset
- File upload size limit in wordpress and php.ini limit
- How to add php to theme to show alt attributes
- Display Title/Description/Caption of custom images on homepage
- Images do not show in the website, but they appear on new tab
- Blank image thumbnails in media library
- Getting extra image links in code with wp_get_attachment_image
- featured image in custom poste type (backend)
- Image Uploader Doesn’t Open Modal in Widget
- Image linking and lightbox
- Dinamically modifying attributes of images on posts
- Run command to optimize images after they get uploaded to WordPress
- How decrease the size of images which are present in uploads folder?
- Large size is not honoured when inserting image
- Issue uploading images
- Get attachment images does not return any attached images
- The most of the images don’t appear, although URLs are correct
- Add two images with Sweet Testimonials
- Breadcrumbs for Single Image page
- Remove “align” attribute on images
- WordPress Images | How to get the cropped image?
- Import existing image as a single post
- How do I change a Themes Header Image?
- Some images 404
- Media Library is not loading on grid view in admin panel
- How can I put pictures next to each other and how can I add a location? [closed]
- How to show file size of featured image? [duplicate]
- WP_Image_Editor – How to save the new size of the image in the sizes metadata
- Is is possible to append .webp to srcset images using wp_filter_content_tags()?
- Could a very long article slow down all website and wpadmin?