Featured images are stored separately in the database and retrieved with a separate function. So it is possible to attach a filter to that function. Regular images are just strings in the post field or in a widget. You can still filter those, but it takes more effort. The filter you built on get_image_tag
can also be used on the_content
(for posts and pages) and widget_text
(for the text widget).
Beware that if you have already used the filter on get_image_tag
, your data attribute is already included as a string in the post, so if you use the filter again it will be included twice, unless you include a test for its presence.
As for the hyphen in the data attribute, that’s simply how the attribute is defined. Just data
is invalid html.
Related Posts:
- What’s the proper way to find and remove duplicate images from posts and the media library?
- get_post_gallery with Gutenberg
- Mixed content warnings after changing site adress from HTTP to HTTPS
- Insert an image into a post by API
- Saving the pre-sanitized filename of an attachment as the Title or Caption
- Creating a rotating header /image slider using theme customization
- Add aditional class to get_avatar when showing image
- Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms…)
- Double thumbnails?
- No srcset for hard-cropped thumbnails
- Loop through child images of a parent for a Nivo Slider
- Slider image issue in wordpress
- Limit author image size
- Remove the http protocol from images
- Retrieving images from a NextGEN gallery
- Query for recent images across multiple posts
- Getting alt text of featured image
- Get image alt attribute just by image URL
- Is there a way to get attachment data?
- WordPress reduces the full size image and uses it as the original
- Show taxonomy list with taxonomy images ( SOLVED)
- get_children() not working properly – Only on one post?
- Warning: getimagesize() [function.getimagesize]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 [closed]
- How to add data attribute to all images in posts [closed]
- How to order images in a post in WordPress 3.3?
- Output random (custom) image size
- WordPress crops images differently on retina screens?
- Image thumbnails not available post migration, but still accessible via direct URL – DB issue
- Override img class in gallery
- Exclude images from “inserted into post” when trying to get attachments
- Set jpeg_quality for certain post-types
- WordPress automatically downscaled images larger that original
- Move Image Captions Inside Link ( tag) if Added
- Sharing images to social media – issue with aspect ratio
- How to add custom classes to figure element only if image has caption?
- I got an issue after i migrated a site
- How to add an image to a custom url?
- I want to use the GD image editor for just one function then switch back to ImageMagick
- 409 error (Conflict) when trying to insert an image into a post
- Exclude image titles from search results
- Facebook og:image issues after https change [closed]
- Does WP create multiple images?
- Thumbnails generated by “add_image_size” are not removed when removing media
- WordPress 3.0 embedded images
- TImthumb not working for absolute path
- Correctly implementing the Facebook Like button
- How to use Facebox in WordPress theme?
- Mass crop images: Landscape images -> Portrait images
- Change image name during uploading sequentially
- Store in media library image uploaded from url
- How to redirect homepage to actual URL?
- Get images attached to a specific page
- add_image_size function not working
- image resizing on post content without css and html tags
- Stop WordPress compressing images? – Quality is terrible
- Cropped image file size larger than original, is it normal?
- Using mysql to replace img src?
- wordpress add image size crop function not working in version 3.8
- Cache issues with images not showing up
- Specific Days, Specific image on Front Page
- How do I display the featured image from an image gallery using a reference in code? (example within)
- caption shortcode inserts blank paragraph
- Doing a bulk replace of images through back-end
- How to change background slider image when hovering on text?
- Can I achieve this with WordPress?
- Built-in image lazy loading: Does it come with a polyfill for older browsers?
- SQL: How to find all attachments that are not used in any posts/pages/custom_post_types
- I would like to set a FULL SCREEN background image to all my pages (same way it is on my home page)
- How to change a theme’s footer image
- Enlarge Featured WordPress Images
- WordPress 4.4.2 upload give error, can’t write is upper directory allowed to be written
- Responsive Images – Defining
- How to attach 1000’s of unattached images
- How to bulk update then save images in wordpress posts
- stop wordpress from resizing feature gif images
- Change wordpress default upload path to another domain
- Alt attribute is not showing while the value is given in Media
- Alternative image sizes are too large
- Modify media file markup output
- Responsive images in Bootstrap 4 slider
- How can I add an “Attach image to this post/page” link on the Add Media lightbox?
- WordPress Is Saving Original Image Only
- Display images from JS?
- How do i replace the title attribute of img tag with the image caption
- Create slider option in editor
- How to make an image bigger with wp_get_image_editor
- Assign one featured image to multiple posts?
- Why are my ‘medium’ images the wrong size
- How can I hide previous_image_link() on first attachment page?
- An image on my site is showing as the wrong image [closed]
- Set padding for all content except images and few more elements
- How to change the alignment of the background image for small screen (tablet/smartphone etc.)
- get_theme_file_uri function not showing background image inside data-setbg in html
- Orientation of featured image in post?
- WPALLIMPORT Exporting images from repeater field [closed]
- What does WordPress media uploader do to image files on upload?
- Site header logo and parallax image on homepage do not display on iPhone
- 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?