Sometimes, WordPress likes wrapping <img ...
tags with extra HTML.
You could try something like as listed on http://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/.
In your theme’s functions.php
file, add the following lines of code near the top:
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
Related Posts:
- Adding HTML within an image title attribute
- alt, title tags not showing
- How do I remove generated HTML around images in posts?
- How to resolve – IE 6 ignores img “width” properties
- Trying to create a mouseover effect in html using Gutenberg editor
- How can I insert an image map into a WordPress blog post?
- Images will not display, when I call them up with html in wordpress, just two blank small spaces [closed]
- How to fix “.webp” being auto-added to the end of image urls
- Changing default img html markup but not in admin back-end?
- Modifying the HTML Output of Inserted Images
- Rewrite inline image markup
- Can’t add image to site via php
- What exactly is the description field when uploading an image?
- HTML Img with data:image src gets sanitized in admin?
- Landing Page with HTML CSS JS and Images on wordpress
- How to link to img src using HTML email template in WordPress
- Relative path not working at all in WAMP local environment
- Display ajax preloader for large images within posts
- Garbled HTML pulled for page description “caption id=attachment…”
- Imagem resolution responsive
- Forcing absolute src links in the RSS feed
- where is images/image.jpg?
- Issues with the excerpt (wordcount/HTML/images)
- Parallax image problem
- Hover images and Videos
- Placing a background image with text over it
- Gutenberg block HTML image rendering override
- remove or update add_image_size
- get the attachement url for the medium sized image
- 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 ID of author_meta image – Attachment Metadata
- Black and White thumbnails
- Alter image output in content
- How can I remove the image attachment ALT field?
- Open the attachment details modal
- Download button for Featured Image in every post – automatically
- Change html structure of all img tags in WordPress
- Get a list of all image sizes that match aspect ratio of original one
- Insert image in comment reply
- Randomly add a ‘ul’ list of images
- Get full image array
- Display number of images actually posted
- media_sideload_image with rewritten urls?
- Different image sizes for home and post pages
- How to set a contact forms total size limit
- Get thumbnail url of custom meta image?
- SVG Featured image not shown in twitter
- upload featured image in custom post type from frontend
- Make medium_large images available to insert into post
- All Images on wordpress site broken
- WooCommerce-like featured gallery
- How to use photo in multiple posts?
- Creating a thumbnail from an image already on the server?
- Alter the image, before save, of a particular image size
- Hero image cropped at different dimensions
- How to handle a background-size: cover image in WordPress?
- Empty alt/title form check in media library
- How To Get The File Extension Of Images Having Different Extensions In A Directory?
- Is it possible to reduce image filesize on the fly (when users enter my website)?
- add_image_size wont work after get_intermediate_image_sizes
- How to get the image-URL from Media-Upload in a post?
- Featured Image Cetegory Not Shown In WordPress
- after migration, newly uploaded images won’t show up
- limit number of images shown from gallery
- Alter the image used for a user who has not uploaded a custom image yet
- Displaying images outside the content
- Fullscreen Page Background without Plugin [closed]
- Allow a specific user role I have created to only upload one image to his media library
- Implementing a modal(lightbox) for all images in all post-gallery posts
- how to regenerate webp et-pb-portfolio-image
- How to increase media image scale limit?
- How do I avoid color distortion of uploaded images?
- Where to put code that customizes API
- When upload a PNG a noise appears in the thumbnails
- How to auto add image caption from image alt?
- How to stop TinyMce from converting image url into ?
- How to automatically load an image inside the post, since it is present in uploads folder
- Broken images/videos after migration – DIVI theme- works ok on Mac OS
- Get “Image CSS Class” value from the Advanced Options section
- After reinstalling wordpress images do not appear in posts?
- Show images from TEXT section on PAGE wordpress
- Where to add my code to auto attach images to existing products
- If file exists with page slug name show image else nothing
- Issue uploading images
- How can I use images that are on the server locally?
- Image filter works on attachement pages but not posts. I can’t get the image ID
- Display different Images depending on the current day
- Get images uploaded to this post in popup on editor screen
- Remove “align” attribute on images
- Uploading Images for a section
- Some images suddenly not appearing
- Paginate Gallery [closed]
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- WordPress: Preload next post images
- Set add_image_size() greater than content width in media box
- Blurry Images WordPress 5.8.1
- Why is inline CSS added to images automatically? [closed]
- How to import external media items into wordpress media library (without using storage)
- How to return responsive images from a sanitize_callback?