Thanks all!
The image_send_to_editor filter was the one I was looking for… thanks @t31os for pointing it out.
Here’s my functions now.
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
This removes inline dimension attributes from images retrieved with the_post_thumbnail()
, and prevents those attributes from being added to new images added to the editor. Doesn’t remove them from images retrieved through wp_get_attachment_image
or other related functions (no hooks in there), but those cases can be processed in the templates files when necessary.
Related Posts:
- Change WordPress image URLs via filter
- Remove title attribute from images
- Disable wordpress image sizes generation
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- How to change Gallery image url in product page ? In function.php?
- I tried to move the featured image below the paragraphs but now it is displaying twice
- Programmatically get images by URL and save in uploads folder
- How to change image type for specific size?
- is it possible to replace the use of gd_lib with imagick or ImageMagick?
- get_the_post_thumbnail_url with an unregistered size
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- Insert an image into a post by API
- hook into completed image upload filter
- Filter Media Library by author or post_parent
- set_post_thumbnail_size not cropping featured images, but reducing proportionally
- How to grab first image attached to post and display in RSS feed?
- Double thumbnails?
- How to display a shortcode caption somewhere other than the_content
- No srcset for hard-cropped thumbnails
- Is it possible to prevent users from uploading small images?
- Can’t Display Featured Image in RSS Feed
- Displaying a featured image (only img url) as the img src?
- add data-attribute to all images inside the_content()
- Filter to modify post_title after image upload?
- Removing Title Tag from Thumbnails
- Setup A Default Featured Image
- When displaying the featured image, is has_post_thumbnail() necessary?
- Find posts without featured image? [duplicate]
- How do I add a featured image to a single post page?
- Get original image from thumbnail URL
- What’s the proper way to use the get_image_tag filter?
- Frontend Post – Allow Only Image File Upload
- attach unattached featured images to respective posts
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- WordPress reduces the full size image and uses it as the original
- Remove image classes from post thumbnail output
- Special purpose photos with each post
- SVG Featured image not shown in twitter
- Woocommerce featured image of page – not product
- Set Post Image Using Shortcode
- Print specific image size in galley loop
- WordPress crops images differently on retina screens?
- Can’t seem to attach uploaded image to post and set it as thumbnail
- How can I add a “data-pin-nopin” the featured image html?
- How to add custom classes to figure element only if image has caption?
- Images stopped loadding after adding SSl
- Setup Featured image on all posts from thesis thesis_post_image custom field?
- Generate images to be associated for tag and category?
- Bulk-add featured images in posts with no featured image
- Should I not compress my jpeg files before uploading to avoid double compression?
- Is it possible to preserve original images in order to change image size later?
- Generating a certain sized thumbnail on the fly?
- How do you import images from a URL in your post?
- How to disable thumbnail filter for a specific template part or image size?
- How can I use wp_save_image_editor_file filter?
- add_image_size function not working
- Why doesn’t WordPress use the smaller sized image?
- What sense makes medium_large_size_h => 0?
- How to set featured image from external url programmatically
- How do I link a featured photo to it’s post?
- Remove Additional image sizes created by theme
- Use default image as var
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- Placing a featured image into header
- How to add thumbnails to posts and pages automatically in a uniformed fixed elegant way?
- resize and crop thumbnail photos
- How do I display the featured image from an image gallery using a reference in code? (example within)
- Using different size thumbnails on different parts of my site… with functions.php?
- attach several images to post + gallery
- How to only show div of caption if caption exists on featured image
- How to echo images Urls from a wordpress post, that are relally in the post
- WordPress Responsive Image ( srcset ) not work properly
- How to Display Image Caption but Not Alt Text
- Force WordPress to always generate a thumbnail for original image
- Get post thumbnail in specific size
- Image alt attribute
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- Why image Thumbnail url is not displaying with custom size?
- How to set a post featured image from an already made custom field
- featured image in custom poste type (backend)
- Why does wp_get_attachment_image_src return the wrong size, when the correct size exists?
- stop wordpress from resizing feature gif images
- set_post_thumbnail_size only working for width
- Dinamically modifying attributes of images on posts
- Newly uploaded images are not updating in featured image
- How to attach post ID to image links in WordPress tinymce editor
- Troubles with code for upload a image
- Declare global variable that can be used on other function
- How might one programmatically set the link for all images in all posts?
- Image filter works on attachement pages but not posts. I can’t get the image ID
- Removing image dimensions from `the_content`
- Black and White Thumbnail in WordPress Gallery
- Why is WordPress loading a different sized post thumbnail?
- Create post thumbnails from images stored outside of uploads directory
- Getting top Image From the Gallery and printing out a thumbnail with Exact Dimensions
- has_post_thumbnail() Returns False on Scheduled Posts
- How to add a link to media file for every image inserted in content?
- Edit multiple posts featured image
- Is there a way to upscale a media library original image to the nearest whole pixel in WordPress?