I believe you can use wp_get_attachment_image_attributes
filter here like so:
function custom_class( $attr ) {
$attr['class'] = 'custom-class';
return $attr;
});
add_filter( 'wp_get_attachment_image_attributes', 'custom_class' );
Related Posts:
- Reject upload of wrong-sized images using the Media Uploader
- Which filters or actions to use after a media upload and delete?
- Settings in ‘Media > Settings’ is ignored when inserting images
- There’s a way to scale media (images) at 50%?
- wp_editor with media buttons
- Force wordpress to see uploads folder media
- Disable TinyMCE Drag and Drop
- Site icons with alpha channel for self-hosted WordPress blog network
- How can I receive the image id using the media box?
- Better solution for managing media attachments with `wp_editor()`?
- Control resizing of uploaded images
- Upload images to remote server
- what happens to existing media files when I switch to year/month directory structure format?
- Can’t upload media, permissions are correct
- Display attachments by ID in a wp.media frame
- Image upload callback in new 3.5 media
- How to wp_upload_bits() to a sub-folder?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Differentiate Featured Image from Post Images upon Upload
- Where do the favicons for Media Files come from
- How to manage a standalone media folder?
- How do I link directly to uploaded files?
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Is wp_read_audio_metadata() function deprecated?
- Media Uploader: get deleted files
- WordPress REST Upload Media
- How can I prevent uploading bmp image?
- How to validate the file name of the Media File Uploads?
- Alter media caption/description conflict in WordPress?
- Restrict the number of images to upload per post
- Restrict file uploads by extension?
- Image size filtering in Media uploader according to custom post type
- Post Specific Uploader
- How to upload imagick resource to media in wordpress
- Select image sizes you want to be uploaded
- How to add a media with PHP
- Generated Images sizes do not match Media Settings Image Size
- Media upload via backend doen’t work after moving site
- Setting higher upload limit
- Multisite media library uploads broken images
- WordPress won’t generate image sizes for certain images
- Different upload path per file type
- Thumbnails produce unwanted gray pixels on white background [closed]
- How do I get allowed Media Library upload file extension list?
- Find unused images?
- Change WordPress Media Manager
- Switch between tabs on “Insert Media” dialog
- Use the WP media uploader dialog for uploading a form attachment (non-admin). Offering progress and drag and drop feedback
- How can I create more upload paths, like a post corresponding to a post title folder used to store images of the same product
- WordPress automatically downscaled images larger that original
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- WordPress Media Uploader in page template (On Front-end)
- “send_to_editor” function returning pdf file name
- making media URL secured
- Is it safe to allow non-admin users access to media uploader
- How to generate thumbnails when needed only?
- add_image_size adds size, but doesn’t upload if source resolution is same as resize resolution
- Set Maximum Width for an uploaded image
- WordPress Bug on IIS ? Problem when uploading image on IIS 7
- Upload media only to DB
- PHP error when trying to upload .mp3 files via Media Library [closed]
- Get images attached to a specific page
- Is it possible to import all files from a uploads DIR into WP media, retaining paths to the files
- Best way to receive special images in posts
- Flat media folder vs multiple directories
- Is there a way in WordPress to convert images to WebP without a plugin?
- Move media files from the root to date folder structure
- Big file upload give HTTP error
- Can you limit the size of media files being uploaded not using php.ini?
- Send media uploads to different directories
- Dynamically determine the width and height of a image file to be cropped & uploaded AFTER form submission given fixed aspect ratio
- Disable image rename on upload
- Open Media Uploader Link in single post or page
- How to change archieve frequency of the media file in uploads folder for wordpress blog
- How can i identify media uploaded to my website that is not being used anywhere anymore?
- image URL changed in wordpress
- Insert attachments from custom uploader into post (regular uploader style)
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- How to limit sizes for specific upload programmatically?
- Serving Images from subdomain in wordpress
- Using WP-CLI “wp media import” to sync files to the media library
- Import media (.xml) does not attribute featured images to posts
- WordPress append -1 to the image name
- MIME type not supporting HEIC support type in WordPress
- Modify Maximum upload file size text in WordPress Media
- Updated wordpress missing image upload area
- Replicate Media Galley Edit view in Add Media View
- How to manually set an attachment in a post?
- Adding attachment custom field metadata to TinyMCE tag
- Sanitizing existing media library paths and page links from foreign characters
- Issue with upload.php with media
- Media files not loading
- How could you allow users to upload a video in within their profile and display it on a wordpress site?
- How to share media between independent blogs?
- WP Capabilities to Add Media, Use Media, But Not Edit Them
- Limit attachment caption characters
- controlling whether upload is attached to post or not
- Media Gallery doesn’t show (using WP-Read Only)
- I am facing problem in loading and downloading Mp3 files
- Does WordPress import export tool keeps the file hosted on the old website?