Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add class to Featured Image/Post Thumbnail

  • @graeme_bryson

    Participant

    Hi – I’m currently trying to add a class to the featured image within posts that appear in the activity loop. I’m using the snippet below (from Stack Overflow) which presumably needs modified to work with BP. Any help would be hugely appreciated as I’m not sure where to go from here.

    
    add_filter('post_thumbnail_html','add_class_to_thumbnail');
    	function add_class_to_thumbnail($thumb) {
    	$thumb = str_replace('<img', '<img class="post-image"', $thumb);
    	return $thumb;
    }
    

    Which would change the output of:
    <img sr c="http://site.co.uk/wp-content/uploads/2016/05/photo.jpg" />

    To:
    <img class="post-image" sr c="http://site.co.uk/wp-content/uploads/2016/05/photo.jpg" />

  • The topic ‘Add class to Featured Image/Post Thumbnail’ is closed to new replies.
Skip to toolbar