[wp-trac] [WordPress Trac] #36996: get_the_post_thumbnail and the usage of class attribute
WordPress Trac
noreply at wordpress.org
Sat Aug 13 15:55:38 UTC 2016
#36996: get_the_post_thumbnail and the usage of class attribute
--------------------------+------------------------------
Reporter: TomasM | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.5.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by wido):
@TomasM I made this little snippet that add again the default classes.
{{{
function _add_again_default_attach_image_class_attr( $attr, $attach, $size
) {
// The class to test.
$classes = 'attachment-' . $size . ' size-' . $size;
// Add the wp classes if not founds.
if ( isset( $attr['class'] ) && false === strpos( $attr['class'],
$classes ) ) {
$attr['class'] .= ' ' . $classes;
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes',
'_add_again_default_attach_image_class_attr', 10, 3 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36996#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list