This will add a field in the attachment edit screen for applying a class to the img tag.
function IMGattachment_fields($form_fields, $post) {
$form_fields["imageClass"]["label"] = __("Image Class");
$form_fields["imageClass"]["value"] = get_post_meta($post->ID, "_imageClass", true);
return $form_fields;
}
add_filter("attachment_fields_to_edit", "IMGattachment_fields", null, 2);
function my_image_attachment_fields_save($post, $attachment) {
if ( isset($attachment['imageClass']) )
update_post_meta($post['ID'], '_imageClass', $attachment['imageClass']);
return $post;
}
add_filter("attachment_fields_to_save", "my_image_attachment_fields_save", null, 2);
Related Posts:
- removing inline styles from wp-caption div
- How to get Images included in Post
- disable WP automatically inserted line breaks after an image
- Find the post an attachment is attached to
- Post slugs and images cannot have same name?
- Replace image attributes for lazyload plugin (data-src)
- Download external images if post is publish
- Can I load posts via Ajax?
- How to remove images from showing in a post with the_content()?
- Unattaching images from a post
- how to display post content without post image?
- How to wrap every image in a post with a div?
- How do I create Comma Separated list of attached image ids?
- how to grab first link in post… and of course call it
- Load post content into div with ajax
- Add an image box besides featured image?
- Remove image from post also removes photo from media library
- Limit function to specific post category
- Post taxonomy from exif data
- Remove inline width from figure
- All my inserted images gets a link to the full image even if it is already full size image
- Remove permalink from images when inserting into post
- WordPress Theory Lesson – Image Columns within posts with alignment?
- how can I put an image in a post with original size
- Get image from post’s gallery
- Image Insert into posts and pages not working after 3.2.1 update
- Copying and pasting emoji in a wordpress post
- Comma separated all attached image ID numbers except featured image ID number
- Modify Image Source With The_Content Filter?
- How to display featured image without it appearing in post?
- Featured Image uploaded, attached and set but only appearing in the media library
- creating front end image uploader that uploads images as posts
- Errors when uploading images in WP 3.5
- Format the Layout of Images In The Edit Post Textarea?
- CSS: How can I show a photo beyond the template’s column, but contained within the browser window? [closed]
- Get all attachment by post excluding featured and content inside
- wp-cli post create & media import issues
- Get attachments for posts that belongs to a specific category
- List all categories with featured image from post?
- Get all images in post and comments like Twitter before post title
- Issue where WP Featured Image will not display
- Thumbnail Image to go in the post aswell
- Remove Featured Image & All Media Uploaded to the Post
- preg_replace not removed “class”
- Upload attachment from external site
- Get URL from all images in a post
- Disable posts generated from image uploads
- Posts page not showing correct image
- Images showing up in Post Editor, but not in Published Post
- Image behind the post’s title
- How to retrieve certain number of images from a wordpress post?
- Show more than 200 images in one post
- Hide thumbnail if there is a gallery on the post
- Image on rss feed on post
- Change the background of each post according to the category
- Where to insert the other site image url for our wordpress post
- select post preview image from nextgen gallery
- How to show a featured image inside a post in only 1 single category
- Attachment image single page
- How to change the order of elements within a post?
- How to call WordPress First Image Post or else Attached Image or Default
- Regarding Posts
- Site/Post preview is not working on all social media
- Delete media from the post but keep my featured image and post
- Display image gallery if more than 1 image
- How do I fix broken links to images in imported posts’ post_content?
- Thumbnails and images in the blog post are not loading
- Post images are not displayed in media library
- Delete attached images from posts
- Blog featured images disappeared on my homepage
- Center crop the feature image
- Schedule image post on download
- Add another feature image box
- ‘posts’ table should not store the absolute image path
- How to show category image if no featured image is set?
- How to make an image appear as a thumbnail in the blog post?
- Manipulating images inside post content
- Output wp_link_pages as raw url
- How can I alternate styling of images in a post? [closed]
- Embed image in post from external url
- Customizing individual images on posts
- Is possible to do this from function.php
- Update all images url imported from HTML pages
- Featured Images link to post parent
- SQL query to remove first image in all posts
- WP Gallery Image Page Issue When 2 galleries share one image
- Post thumbnail dependant on category
- Latest news mini images
- Why can’t I see my attachment page information for an image?
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- Only show posts with image and the correct ammount of posts in loop
- Extra Theme – Fit image inside of Featured Post Slider
- Is there any SEO impacts on unattached vs attached images for a post in WordPress?
- Full width images within post content
- Import alt text in set_post_thumbnail
- Broken images after importing posts and opening in Gutenberg
- Search doesn’t display posts with images
- Displaying all images from a WordPress post (including media library)
- Inside post image title has been posting as a post title on my main post page
- Download button under all images WordPress