this is a function, that unwraps images from p tags inside the_content
/**
* WP: Unwrap images from <p> tag
* @param $content
* @return mixed
*/
function so226099_filter_p_tags_on_images( $content ) {
$content = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '\1', $content);
return $content;
}
add_filter('the_content', 'so226099_filter_p_tags_on_images');
Related Posts:
- Stripping the_content() from images then displaying them seperately
- 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?
- get attachment title based on attachment id
- Media Upload Folder – how to manage
- Wrong image dimensions in Insert Media after add_image_size()
- PHP Fatal error: Call to undefined function download_url()
- Remove P tags from images
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- Upload multiple images in a custom metabox
- How can I hide media library images from general users?
- WordPress speed slow after .5 million single image post via wp-cli
- How to add php to theme to show alt attributes
- Why won’t these imported images show up?
- Remove rel=”attachment wp-att-XX”
- Using Taxonomy Image code with my get_categories code
- Generate image size, based on the image-orientation
- Rename image during upload using date and time stamp?
- How to Add extra option to Image Block Settings?
- Upload thousands of images to WordPress without plugin?
- Images in the Twenty Fourteen theme
- Get author ID with attachment ID
- Show Post Excerpt in Image Attachement
- Automatically replace original uploaded image with large image size
- Problem with loading images from child theme CSS file with relevant path
- wp_get_attachment_url with specific image_size?
- Bulk edit Gutenberg single images to change from linking to media file to attachment page
- is it possible to crop cover images in buddypress?
- Any specific reason why images do not show on site?
- Why no images on a fresh WordPress installation?
- How to upload images in a specific folder using API
- AJAX – save an $_FILES picture in media library
- How to stop thumbnail generation from some images and different size thumbnail generate
- How can I use cached images in an AJAX response?
- Searching for any images in media library displays “no media found”
- How can I filter image HTML to add schema.org attributes?
- How to get file URL from media library
- How to implement secure frontend image upload? [closed]
- Resize header image
- some images not appearing on the website after migration [closed]
- WP 5.3 Removing Default WordPress Image Sizes
- Include an image within auto the_excerpt?
- WordPress images not cropping properly
- HowTo: develop WP template with dynamic background image
- Clicks registering on Preview DNS site
- A little confused as to what add image size actually does
- Get thumbnail URL :)
- Right click© images: protection
- What did I do WRONG?
- Images not found after migrating WordPress website
- Large image not showing dimensions in Media Library
- Change logo image condition based on url
- How to insert image path in database to display product image in wp-admin?
- Apply nextgen-gallery lightbox effect [closed]
- How to create a title images for different posts?
- How can I externally retrieve a post’s custom sized image
- Why is my table background image not showing in wordpress?
- WordPress Media Library – how to “uncache” images
- View photo album without having to scroll down for each picture
- How can i sorting and display image order by siz in media library?
- x2 images for retina?
- Is there a way to add a featured image to an image/file attachment page?
- Media Library Cleanup A Thought Exercise
- Save media files (images) to database instead of the filesystem
- i want to change URL of WordPress image or rewrite in runtime
- Site only working in browser where I created it
- After migration, all featured images using accentued characters in their file names are displayed “blanked”
- Adding numbers to an image based on co-ordinates
- A query to substitute images paths in gutenberg (website migration)?
- link not working in image section
- Images missing from Blog post page
- Page size too big due to images
- WP Large Images crash page
- WordPress can’t detect any thumbnails size?
- How to display posts with images in fullscreen slider
- Are WP images responsive by default?
- Prevent WordPress from creating individual size images
- wordpress images not showing properly
- Keep the original ratio in a thumbnail image
- What is the best way to handle Ajax image upload on front end?
- Why doesn’t WordPress make thumbnails for videos?
- Plain image uploading – no links, no classes, no sizes
- Thumbnail gallery by date and taxonomy
- Adding multiple images on my site – without using plugins [closed]
- How do I embed an image at actual size?
- Display ajax preloader for large images within posts
- > added to images link in WordPress
- Insert image doesn’t pickup right size
- Thumbs and pictures not showing anymore
- Storing images on a local site
- Images will not attach to posts after site migration
- How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices
- Forcing absolute src links in the RSS feed
- Stop underlining image links
- How to get attached image alt text in media.php?
- Why some images are not allowed to be edited only for thumbnails?
- problems with alt text not appearing in source code