Take a closer look at get_image_tag() which can take a lot of parameters like $id
, $alt
, $title
, $align
, $size
.
If you look even closer you’ll find the get_image_tag_class
filter to change the image class names (like class, ID, align and size).
You can use the filter within your functions.php
like this:
Note: This will still return an empty tag like: class=""
function strip_image_class($class, $id, $align, $size) {
return '';
}
add_filter('get_image_tag_class', 'strip_image_class', 0, 4);
Update: To completely remove everything related to the class you’ll have to filter the $html
:
function strip_entire_image_class($html) {
return preg_replace('/ class="(.*)"https://wordpress.stackexchange.com/", '', $html);
}
add_filter('get_image_tag', 'strip_entire_image_class', 0, 4);
Related Posts:
- What’s the best way to use the Featured Image for responsive web design?
- How do I hook into WordPress to save an uploaded photo as an alternate size to an existing photo?
- How to check if image is already stored in a site’s post database? (network)
- Adding a custom image upload size and making it selected by default?
- Hide custom image sizes from media library
- How to draw media details for Isotope gallery using Photoswipe
- Create Image Uploader for Widget
- Permanently remove first image from posts
- Admin Media grid view images won’t load
- WordPress remove EXIF Data from specific Thumb
- How to resize image on client-side before upload?
- Adding Featured Image to Post programatically
- Get a Page’s attachments in Gallery order
- How to get custom image size for image uploaded in Customizer
- Using wp_get_image_editor in a standalone script
- Assign a picture URL to a page via PHP
- Styling images coming from another blog
- How to scale image with equal width and height without distortion?
- IMG src weird behaviour inside a single post loop
- Escape post image attachments added to template
- Display post image with fancybox
- How to get media objects
- PHP code to call image Caption, Alternative Text, and Decription?
- Echo URL of large version of Featured Image
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- How to get specific image in media library with php
- hover image appears below placeholder instead of overlayed
- Add custom url to featured image
- Best practice for migration friendly images in posts/pages?
- Get the post ID and display the images
- Responsive Header for Phone
- Unread Repeater field IMG alt not working
- Upload multiple images to a Woocomerce product
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- Accessing an image folder inside public web directory
- Why my image upload button is not working in wordpress widget area?
- How to make own crop image function for WordPress plugin
- WordPress automatically adds links to uploaded images
- WordPress function when file is uploaded, deleted or edited
- How to loop through all the attached images in a post, and get their url one by one
- Clickable image link sends people to wrong URL
- Only show image from custom field when present
- Timthumb.php image gallery not working on Multisite WordPress
- Where are the src and srcset sizes coming from?
- HTML showing after PHP code in tag
- trying to get wp_get_attachment_url to output clickable link
- Change default gallery images – Currently they are displaying full size imagese
- Creating black and white copy of an image [closed]
- Shortcode function doesnt work without caption
- Get featured image with custom size outside WordPress
- Images Uploaded saving onto older/previous year folders
- Display an image based on field value
- Add valid XHTML closing img tags to WordPress galleries
- How to set a featured image (thumbnail) with PHP?
- Convert canvas to image and upload image to server
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- How to Make Thumbnail of Post Stay Animated
- Adding a ‘style=’ bit to image_send_to_editor output
- Convert all uploaded PNG files to PNG-8 format
- CSS images don’t show up with bloginfo
- Some problems in custom widget
- Displaying images outside the content
- Checking page before applying image restrictions while uploading
- Generate images with html2canvas and the woocommerce api
- Change extension to .jpg when webp is not supported
- Prepend to all image URLs with PHP, only for mobile devices
- Retrieve alt text by referencing the img src
- Show next image in array if page is revisited by same logged user
- Update Images after edit via php
- Configure WordPress to Use Responsive Image Rendering
- Replace background image with post thumbnail in shortcode
- How to get the url of the entry in which an image belongs
- Get list of posts from attachment
- Get the image title and alt from custom query
- How to include different html tags in the header for different pages?
- How to always display full size image
- Retrieving specific images from Media Library
- How do I routinely extract the thumbnail of the most recent post?
- add class to background image
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Save the outputted image into the Media Library, with a different filename and extension
- Pass php to database in JQuery: With AJAX?
- Creating image gallery in wordpress
- Image limit from 1 to 5
- Name Input from widget displays Sidebar name instead of saved data
- Gallery requires a featured image but does not show it in posts/pages
- Changing 2011 theme header image based on user dropdown
- images in wordpress themes
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- How do I return an image from a script
- Display Post Titles on top of the_post_thumbnail()
- add if statement to the featured image
- How to automatically convert images to WebP on WordPress?
- Understanding responsive imagery
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- bloginfo url in javascript
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload
- Using Featured Image as Hero Background in Word Press
- Adding caption to all images inside an article