This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Alternate featured image post list thumbnails

  • Creator
    Topic
  • #18782
    mike-se
    Participant

    Hi!

    I’m trying to alternate the post list featured image thumbnails on a custom layout post list view, setting it differenet on a post by post basis, much like many online newspapers would do, but it doesn’t seem to work.

    It always gets overwritten by the Primary Posts Display setting of either theme options or layout post list options so it’s either a small or full width thumbnail on the entire post list, but never alternate or custom.

    Any guidance on how I could accomplish this?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #18788
    Jason Bobich
    Keymaster

    Try playing around with the filter “themeblvd_get_thumbnail_size” — See the function themeblvd_get_thumbnail_size() in /framework/includes/media.php.

    In theory something like this, might work:

    function my_get_thumbnail_size( $size, $location, $sidebar_layout ) {
    
    	$size = get_post_meta( get_the_ID(), '_tb_thumb', true );
    
    	if ( $size == 'hide' ) {
    		$size = null;
    	} else if ( $size == 'full' ) {
    		$location == 'featured' || $sidebar_layout == 'full_width' ? $size = 'tb_large' : $size = 'tb_medium';
    	} else if ( $size == 'small' ) {
    		$size = 'tb_small';
    	}
    
    	return $size;
    }
    add_filter( 'themeblvd_get_thumbnail_size', 'my_get_thumbnail_size', 10, 3 );

    This is basically just taking the size from the option, that is normally meant for single post only, and using it always.

    #18790
    mike-se
    Participant

    Fantastic! Thank’s Jason. I really appreciate this

    #18821
    mike-se
    Participant

    Ok. So this is what I ended up with, and it seems to work. Please let me know if somethings wrong here 😉

    So I wanted to alternate the featured image thumbnails on a custom layout post list view, setting it custom size on a post by post basis – only when the page is_front_page or is_home.

    On all single pages I want it to be a full featured image thumbnail.

    function my_get_thumbnail_size( $size, $location, $sidebar_layout ) {
    
    	$size = get_post_meta( get_the_ID(), '_tb_thumb', true );
    
    	if ( is_front_page() && is_home() && $size == 'hide' ) {
    		$size = null;
    	} else if ( is_front_page() && is_home() && $size == 'full' ) {
    		$location == 'featured' || $sidebar_layout == 'full_width' ? $size = 'tb_large' : $size = 'tb_medium';
    	} else if ( is_front_page() && is_home() && $size == 'small' ) {
    		$size = 'tb_small';
    
    	} else $size = 'tb_large'; {
    
    	}
    	return $size;
    }
    add_filter( 'themeblvd_get_thumbnail_size', 'my_get_thumbnail_size', 10, 3 );
    #18822
    mike-se
    Participant

    Oh, and it’s supposed to be

    else $size = 'tb_medium';

    .

    #18827
    Jason Bobich
    Keymaster

    This:

    // ...
    	} else $size = 'tb_large'; {
    
    	}

    Should be this:

    // ...
    	} else {
    		$size = 'tb_large';
    	}

    Or, based on your last comment, I assume this?

    // ...
    	} else {
    		$size = 'tb_medium';
    	}
    #18833
    mike-se
    Participant

    Thank’s Jason!

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.