When developing a site, it can be useful to know the attachment ID of the image you’re looking at. I use it along with wp cli to regenerate specific thumbnails: wp media regenerate 1235
This adds a class containing the attachment ID to images, so you can right click and inspect element to know the appropriate ID.
<?php | |
/** | |
* Attachment ID on Images | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/add-attachment-id-class-images/ | |
*/ | |
function be_attachment_id_on_images( $attr, $attachment ) { | |
if( !strpos( $attr['class'], 'wp-image-' . $attachment->ID ) ) | |
$attr['class'] .= ' wp-image-' . $attachment->ID; | |
return $attr; | |
} | |
add_filter( 'wp_get_attachment_image_attributes', 'be_attachment_id_on_images', 10, 2 ); |