We use the_post_thumbnails to get our images displayed.
We want to use them with a specific class called "test" but we cant manage it!
We use this code:
<?php the_post_thumbnail('pin-photo-large', array('class' => 'test')); ?>
But the output of the image seems like this:
class="test wp-post-image"
How can we overcome this issue and get an output like this ?
class="test"
Update: Add this to your functions.php file:
remove_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' );
Explanation: In media.php, the _wp_post_thumbnail_class_filter function adds the wp-post-image class to post thumbnails. By removing the begin_fetch_post_thumbnail_html action hook (located in default-filters.php), the function will no longer apply to the_post_thumbnail.
Old answer below:
I also searched for a proper way to filter out the wp-post-image class, alas to no avail. The only solution I figured out was to edit a (gasp!) core file: media.php and replace this:
function _wp_post_thumbnail_class_filter( $attr ) {
$attr['class'] .= ' wp-post-image';
return $attr;
}
by this:
function _wp_post_thumbnail_class_filter( $attr ) {
return $attr;
}
There's certainly a better way to do this than to patch a core file, but this can be a good temporary solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With