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.

Featured image sizing (as per tutorial) not working with 2.0b2

  • Creator
    Topic
  • #20173
    Israel Curtis
    Participant

    http://dev.themeblvd.com/tutorial/how-to-setup-small-featured-images-on-single-posts/

    This recent tutorial provides code that should allow us to display something other than the full-size featured image on single views, but not only does the code not appear to do anything in my child theme functions.php, digging into the jumpstart codebase and the “themeblvd_single_atts” filter shows no such “crop” array item to be filtered with a size other than Full. Array key ‘thumbs’ seems to be simply set to true or false in class Theme_Blvd_Frontend_Init

    $this->atts = apply_filters( 'themeblvd_single_atts', array(
    				'location'		=> 'single',
    				'content'		=> 'content', // We don't want excerpts to show on a single post!
    				'thumbs'		=> $thumbs,
    				'show_meta' 	=> $show_meta,
    				'show_sub_meta' => $show_sub_meta
    			));

    am I missing something?

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

    In the tutorial example it uses the crop size tb_medium. This crop size was added in beta2. Try regenerating your thumbnails. I’m thinking you updated, and now none of your images have the tb_medium crop generated, thus WordPress is pulling native image, and so the code appears to do nothing.

    By default there is no “crop” in the array. This is why you’re filtering it on. 😉

    #20175
    Israel Curtis
    Participant

    actually, this is an image that I just uploaded now, so I would think with beta2 installed for some time now, that size would have been generated? I’ve tried other sizes too, and nothing happens.

    I figured that’s why I’m adding “crop” — but I also tried to follow the trail and see where my additional “crop” array key would be utilized, and couldn’t find it in any of the code for displaying single posts…

    #20189
    Jason Bobich
    Keymaster

    I tried the code on my end again, and it’s definitely correct.

    I think the confusion is that there’s currently a bug with the tb_x_large, tb_large, and tb_medium crop sizes with the new beta, as someone has pointed out to me today.

    Try using another crop size other than those three, or try applying the patch and re-uploading/regenerating crop sizes.

    but I also tried to follow the trail and see where my additional “crop” array key would be utilized, and couldn’t find it in any of the code for displaying single posts…

    If you’re curious how it works, it works by adding a global variable for the crop size. So when you call themeblvd_get_att('crop') at any point after this, you get that size you set. This gets utilized themeblvd_get_post_thumbnail() in /framework/media.php. That’s where the trail ends on this.

    #20228
    Israel Curtis
    Participant

    So after trying all the crop sizes and still getting nothing, I had a realization. I’m setting up this site as a page-based CMS, and I don’t think this hook works for pages, only posts. I noticed that the custom CSS from the tutorial had a “article.single .featured-item” selector, which didn’t exist in my page source. Once I changed the CSS to this, I finally had control of the image:

    article.single .featured-item,
    article.page .featured-item {
      float: left;
      margin: 0 20px 20px 0;
      max-width: 250px;
    }

    But really I was still shrinking the full-size image via CSS. Which made me think that your filter hook was never firing for page views:

    add_filter('themeblvd_single_atts', 'my_single_atts');

    So is there another hook to provide this functionality of automatically inserting the featured image for pages too?

    I’m noticing, as I create this page-based hierarchical CMS site, that there are quite a few “gotchas” when it comes to using pages. There are many features that are tailored for Posts, but don’t work quite right when you’re using Pages (my other thread about excerpts, for example). With post grids and lists, even when you select pages as a source, the only method for indicating which pages is a list of slugs (not dynamic, and most people don’t know the slugs by heart) — when maybe an option to fetch all child pages would be more useful (and more typical for static page-based sites). Also the ordering doesn’t have an option for “menu_order”, which is very commonly used to arrange the way pages are displayed (also often with custom post types).

    For me, Pages are just another post type that live alongside my custom post types in the CMS, a familiar item for most wordpress users, and the core Posts are used for reverse-chronological blog items. So I’m wondering if maybe the old tried-and-true Pages could get a little more love in JS2.0?

    #20242
    Jason Bobich
    Keymaster

    This is sort off the top of my head, but something like this should accomplish the same thing, including single posts and pages.

    function my_global_atts() {
    	if ( is_singular() ) {
    		themeblvd_set_att('crop', 'tb_medium');
    	}
    }
    add_action( 'wp', 'my_global_atts' );

    http://codex.wordpress.org/Function_Reference/is_singular

    I probably won’t add more complication to the interface by doing more options to pull from pages, because I find there’s really no end to the different things people want to do that I talk to. But for what you’re wanting to do, you could just select to pull from a “Custom Query” and it could be as simple as something like this maybe:

    post_type=page&orderby=menu_order
    #23955
    beckythetechy
    Participant

    This tutorial no longer exists – is it somewhere else? I really need to change the featured images to be thumbnails instead of full width…

    #23964
    Jason Bobich
    Keymaster

    Hi Becky,

    The article is still at the same link that the original poster provided. I just double checked and it’s still there. Here’s the link again:

    http://dev.themeblvd.com/tutorial/how-to-setup-small-featured-images-on-single-posts/

    #23967
    beckythetechy
    Participant

    I just clicked again and I’m getting the same message: “apologies but the page you’re looking for can’t be found.”

    I’ve tried from 3 devices & 2 browsers…

    #23969
    Jason Bobich
    Keymaster

    Aw, I see now. I made the article private because it’s no longer up-to-date. But it has a missing piece now — that being that the featured image would also have to be moved to within the entry-content DIV. This can be done by copying content.php to your child theme and moving the featured image into that area.

    #23970
    Jason Bobich
    Keymaster

    1. Ok, here’s how to actually filter in your custom featured image size:

    /**
     * Filter global attributes initially setup
     * by the framework when a single post is
     * displayed.
     */
    function my_single_atts($atts) {
    	$atts['crop'] = 'tb_medium'; // crop size used for featured image
    	return $atts;
    }
    add_filter('themeblvd_single_atts', 'my_single_atts');

    2. Then you need to move the featured image to within your content. So copy content.php to your child theme, and then move the featured image from where it is to within the <div class="entry-content"></div>

    3. Then apply CSS to float the thumbnail left. Something like the following, but may need to some tweaks depending on exactly what you do.

    article.single .featured-item {
      float: left;
      margin: 0 20px 20px 0;
      max-width: 250px;
    }
    #23972
    beckythetechy
    Participant

    I see it now, thanks for the info about entry- content div. all my customers like using square images or images that aren’t wide enough this makes them look good on mobile but terrible on desktop.

    Example: http://jennicechoo.com/2015/11/08/why-start-them-early-and-why-start-them-young/

    That looks horrendous on a large screen! I like for them to use featured images so they look nice in lists and hate for them to also have to insert into their content.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.