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"
Add this to your
functions.php
file :Enjoy
Update: Add this to your
functions.php
file:Explanation: In
media.php
, the_wp_post_thumbnail_class_filter
function adds thewp-post-image
class to post thumbnails. By removing thebegin_fetch_post_thumbnail_html
action hook (located indefault-filters.php
), the function will no longer apply tothe_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:by this:
There's certainly a better way to do this than to patch a core file, but this can be a good temporary solution.