Is there a way to create and resize duplicate images in WordPress media library?

The idea is that I upload a single image, which can then be duplicated, resized and cropped to a different aspect ratio within the WordPress backend for use in different places within content.

I can’t seem to find a way of doing this via a plugin (it’s a bit of a fringe case), but is there a way to do this programatically?

Related posts

2 comments

  1. WordPress already supports different sizes for attachments:

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

    If you want the size you add to appear in the sizes dropdown when inserting an image into a post, you’ll need to use the image_size_names_choose filter. Example:

    //add the new image size
    add_image_size('custom_size', 200, 200, true);
    
    //add "custom_size" to the dropdown
    add_filter('image_size_names_choose', function($sizes) {
        return array_merge($sizes, array(
            'custom_size' => __( 'Custom Size' ),
        ));
    });
    

    Using the above code, whenever you upload an image, a 200 by 200 thumbnail will be generated. When you insert that image into a post you’ll be able to select that size.

  2. Do you have access to the theme functions.php file? If so, I recommend adding a custom image size and use that in conjunction with the Post Thumbnail Editor plugin.

    For instance, you could add a custom image size with the desired aspect ratio in the functions.php file. Then WordPress will generate a file of that size when uploading the image. In Post Thumbnail Editor, you can then re-crop the generated images that need it.

Comments are closed.