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.

Image Sizes

  • Creator
    Topic
  • #1265
    twk886
    Member

    Another issue in addition to the Photo Captions issue I posted earlier today…

    Since I’ve updated the theme from 2.0.1 to current, my child theme’s functions.php file is no longer adjusting the image sizes as before.

    I see some different function code for image sizes in theme-functions.php but I don’t understand how to make it work in my child theme. When I try copy/pasting that code into my functions.php file, I get a server error when loading the site. Yikes!

    I checked your documentation and the link to the “Editing Framework Functions” tutorial just leads to the Jumpstart homepage… no tutorial. http://www.wpjumpstart.com/tutorial/editing-framework-functions/

    What is the new protocol for changing the default image sizes? Here’s what I was doing before that’s no longer working:

    function my_image_sizes( $sizes ) {
        $sizes['large'] = array(
            'width' => '918', // Your new width
            'height' => '9999' // Your new height
        );
        $sizes['medium'] = array(
            'width' => '668', // Your new width
            'height' => '9999' // Your new height
        );
        $sizes['slider large'] = array(
            'width' => '921', // Your new width
            'height' => '275', // Your new height
    	'crop' 	=> 'true'
        );
        $sizes['slider staged'] = array(
            'width' => '530', // Your new width
            'height' => '235', // Your new height
    	'crop' 	=> 'true'
        );
        $sizes['grid_4'] = array(
            'width' => '271', // Your new width
            'height' => '170', // Your new height
    	'crop' 	=> 'true'
        );
        $sizes['grid_6'] = array(
            'width' => '315', // Your new width
            'height' => '197', // Your new height
    	'crop' 	=> 'true'
        );
        return $sizes;
    }
    add_filter( 'themeblvd_image_sizes', 'my_image_sizes' );

    Here’s what I tried that threw the server error:

    function alyeska_image_sizes( $sizes ) {
    	$sizes['slider-large']['width'] = 921;
    	$sizes['slider-large']['height'] = 275;
    	$sizes['slider-staged']['width'] = 530;
    	$sizes['slider-staged']['height'] = 235;
    	$sizes['large']['width'] = 918;
    	$sizes['large']['height'] = 9999;
    	$sizes['medium']['width'] = 668;
    	$sizes['medium']['height'] = 9999;
    	$sizes['grid_4']['width'] = 271;
    	$sizes['grid_4']['height'] = 17;
    	$sizes['grid_6']['width'] = 315;
    	$sizes['grid_6']['height'] = 197;
    	return $sizes;
    }
    add_filter( 'themeblvd_image_sizes', 'alyeska_image_sizes' );

    Thanks.

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

    Hello,

    First off, I’m a little confused by this question because to my knowledge, nothing should have changed. I could be wrong, but I’m looking everything over and while things have been moved, it’s all the same. You’ve got the same array with the same filter.

    The editing framework functions tutorial you’re looking for is here, but it shouldn’t matter in this case. You should be able to do this simply with filters. You don’t need to edit any functions.

    Both of what you’re doing are right as far as I can tell. However, if you’re adding the filter from your Child theme’s functions.php, I’d assume it’s getting overridden by the theme’s filter on slider image sizes. But that should have been the case before you updated, also. To combat that, you’d give your filter a priority. — http://codex.wordpress.org/Function_Reference/add_filter

    Or, you can include the framework at the top of your Child theme’s functions.php as allowed starting with framework v2.1 and simply place all of your filters after that. See the child theme example’s functions.php that now comes with the new theme package for what I’m referring to.

    But you shouldn’t be getting a PHP errors from what you’re doing. What is the PHP error you’re getting? When there’s an error, it’s always helpful to read it, as it generally tells you what the issue is. 😉

    #1267
    twk886
    Member

    Also tried this (changed the function to my_image_sizes), which didn’t throw the server error, but it also didn’t incorporate the changes:

    // Image Sizes
    function my_image_sizes( $sizes ) {
    	$sizes['slider-large']['width'] = 921;
    	$sizes['slider-large']['height'] = 275;
    	$sizes['slider-large']['crop'] = true;
    	$sizes['slider-staged']['width'] = 530;
    	$sizes['slider-staged']['height'] = 235;
    	$sizes['slider-staged']['crop'] = true;
    	$sizes['large']['width'] = 918;
    	$sizes['large']['height'] = 9999;
    	$sizes['medium']['width'] = 668;
    	$sizes['medium']['height'] = 9999;
    	$sizes['grid_4']['width'] = 271;
    	$sizes['grid_4']['height'] = 170;
    	$sizes['grid_4']['crop'] = true;
    	$sizes['grid_6']['width'] = 315;
    	$sizes['grid_6']['height'] = 197;
    	$sizes['grid_6']['crop'] = true;
    	return $sizes;
    }
    add_filter( 'themeblvd_image_sizes', 'my_image_sizes' );

    And lastly, I know in my existing code there should be dashes in [slider-large] and [slider-staged] – that doesn’t work, either :-/

    #1269
    twk886
    Member

    Just read your reply. I will try the priority trick (if I can figure it out… I’m not a coder, just fumbling around here!)

    #1270
    Jason Bobich
    Keymaster

    Aw, so the PHP error is because of duplicate functions, which the error should say something like “cannot re-define function blah blah” — Yeah that make sense. “alyeska_image_sizes” is a function already used. You’d have to make your own.

    But what you’re posting here should work assuming you’re taking into account the order in which things are added as I discussed in my last reply.

    #1271
    Jason Bobich
    Keymaster

    Just read your reply. I will try the priority trick (if I can figure it out… I’m not a coder, just fumbling around here!)

    Ok, do this:

    1) Open up the functions.php of the new Child theme example. See the top section where the framework is included. Copy this section to the top your Child theme’s functions.php.

    2) Now place your code after this section you just pasted in:

    // Image Sizes
    function my_image_sizes( $sizes ) {
    	$sizes['slider-large']['width'] = 921;
    	$sizes['slider-large']['height'] = 275;
    	$sizes['slider-large']['crop'] = true;
    	$sizes['slider-staged']['width'] = 530;
    	$sizes['slider-staged']['height'] = 235;
    	$sizes['slider-staged']['crop'] = true;
    	$sizes['large']['width'] = 918;
    	$sizes['large']['height'] = 9999;
    	$sizes['medium']['width'] = 668;
    	$sizes['medium']['height'] = 9999;
    	$sizes['grid_4']['width'] = 271;
    	$sizes['grid_4']['height'] = 170;
    	$sizes['grid_4']['crop'] = true;
    	$sizes['grid_6']['width'] = 315;
    	$sizes['grid_6']['height'] = 197;
    	$sizes['grid_6']['crop'] = true;
    	return $sizes;
    }
    add_filter( 'themeblvd_image_sizes', 'my_image_sizes' );

    ======

    The reason for this is because WordPress loads the Child theme’s functions.php first. So for example, if you were to add a filter to change the slider image size, then after that the theme adds its filter to change the slider image size on the framework. So your filter becomes irrelevant.

    However, by including the framework’s themeblvd.php at the top of your child theme, we’re reversing this process. Now the Parent theme comes first and now all of your Child theme’s functions come after.

    =====

    Also remember that image size changes don’t happen instantly. You have to either re-upload the images or re-generate your thumbnails. — http://wordpress.org/extend/plugins/regenerate-thumbnails/

    #1272
    twk886
    Member

    Yes! That worked. Thanks so much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The forum ‘Alyeska Responsive WordPress Theme’ is closed to new topics and replies.