Support » Fixing WordPress » Add more image sizes

  • Resolved valfreixo

    (@valfreixo)


    Howdy.

    I’m creating a site about music with interviews, video and photo galleries among other features. It’s a very elaborate them with almost all been customized and tailored.

    troughout the template, I’m using several image sizes. When I upload an image, QP creates 3 image sizes. The problem is that I need around 10 diferent sizes. Is there any plugin I can use to do this? Or a way to extend worpdress in way I can code several additional image sizes?

    Thank you in advance

    Zen

Viewing 15 replies - 1 through 15 (of 21 total)
  • Guys, sorry about the bump. But I’m really stuck on this.

    Thank you for any direction. Not looking for the complete solution. Just for a direction were I can start building it

    Hi,

    Its better that you can change image sizes from the coding area and set the image size upon the requirement.

    [signature moderated Please read the Forum Rules]

    I’m building this site for reporters that cover music events. They have like 30 or 40 photos each day. I’m just looking for a way to create all the sizes previously just to ease on the work.

    All the photos have the 9 by 6 ratio so every image resized will be a perfect fit. Also can’t stretch/contract image sizes because they simply don’t want it. Tough huh?

    Thank you for your time in helping me out

    Zen

    Ok, found the solution

    Please share your solution with us so that someone trying to do the same can benefit from it. Thanks!

    I’m also asking you to post your solution! I could really use this feature.

    try something like this:

    if( FALSE === get_option("frontpage_size_w") )
    {
    	add_option("frontpage_size_w", "260");
    	add_option("frontpage_size_h", "0");
    	add_option("frontpage_size_crop", "0");
    }
    else
    {
    	update_option("frontpage_size_w", "260");
    	update_option("frontpage_size_h", "0");
    	update_option("frontpage_size_crop", "0");
    }
    
    function additional_image_sizes( $sizes )
    {
    	$sizes[] = "frontpage";
    
    	return $sizes;
    }
    add_filter( 'intermediate_image_sizes', 'additional_image_sizes' );

    the above example will add size called “frontpage” to the list of image sizes. for each additional image size, you will have to add its name to the $sizes array and add its width, height and crop values to wp’s options.

    like this:

    if( FALSE === get_option("frontpage_size_w") )
    {
    	add_option("frontpage_size_w", "260");
    	add_option("frontpage_size_h", "0");
    	add_option("frontpage_size_crop", "0");
    
    	add_option("anothersize_size_w", "260");
    	add_option("anothersize_size_h", "0");
    	add_option("anothersize_size_crop", "0");
    }
    else
    {
    	update_option("frontpage_size_w", "260");
    	update_option("frontpage_size_h", "0");
    	update_option("frontpage_size_crop", "0");
    
    	update_option("anothersize_size_w", "260");
    	update_option("anothersize_size_h", "0");
    	update_option("anothersize_size_crop", "0");
    }
    
    function additional_image_sizes( $sizes )
    {
    	$sizes[] = "frontpage";
    	$sizes[] = "anothersize";
    
    	return $sizes;
    }
    add_filter( 'intermediate_image_sizes', 'additional_image_sizes' );

    you can put this code in the functions.php file, or create a plugin out of it.

    cheers 😉

    also, i’ve recently discovered this awesome plugin called “scissors”, which allows you to crop image after upload via javascript, and it really works very well 🙂

    correction: when setting crop option, it should be written like this:

    add_option("anothersize_crop", "0");

    instead of:

    add_option("anothersize_size_crop", "0");

    no need for “_size” after size name and before “_crop”, sorry about that.

    can we change the image size name?
    (from imagename-333×222.jpg to imagename-medium.jpg)

    MK009

    (@mk009)

    aesqe, I can’t get your code to work with 2.8. Really looking for this functionality, has 2.8 possibly changed the filter or something?

    onel0ve

    (@onel0ve)

    without upload can i resize image ?.like i post image link of tinypic ?? then

    MK009

    (@mk009)

    onel0ve, if you hotlink the image hosted on tinypic then resize it with html you can. You would do this just from the post screen.

    MK009:

    the code works, but you won’t see the sizes in the admin interface – check your uploads folder to see the result, that is different sizes of uploaded images.

    or if i misunderstood you, please explain a bit further so i may be of assistance 🙂

    Woohoo, thanks aesqe. This will sort out all image chopping for my project. 😀

    And definitely worth noting that there won’t be any additions to the admin interface.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Add more image sizes’ is closed to new replies.