0

Is there a way to limit the dimensions of the full size uploaded image (made normally through the Media library)?

I have clients that upload huge images files with resolutions sometimes greater than 5000 x 5000. They don't quite understand why Wordpress/websites have a hard time with these images.

Limiting "Full" size images seems like a great solution. Is it possible via functions.php?

  • I know there is a way to do this as I've seen some Plugins that allow this feature, I will have a look into it if no one gives you an answer – Stephen Jan 26 '16 at 19:14
  • I'd love to do it manually, but I've just discovered this plugin: wordpress.org/plugins/imsanity – Django Reinhardt Jan 26 '16 at 19:14
  • I have the solutions I think, I will post it – Stephen Jan 26 '16 at 19:15
  • We have used info from this codex page to set img sizes for media (although you set them also in the back-end in Settings/Media ) and used this wpse answer to keep the folder on the server 'clean and uncluttered'. For us it works like a charm and the client is also satisfied with the results. – Charles Jan 26 '16 at 19:38
  • 1
    Imsanity plugin is good for sure, but if you want to do handle both image optimization and size limiting, I find wordpress.org/plugins/ewww-image-optimizer is a better option now they recently also added image resizing functionality. – Trevor May 18 '16 at 1:46
2

So I've found this WP_Image_Editor in the CodeX. Basically by adding the code below it should automatically resize an image :)

Code:

$image = wp_get_image_editor( 'cool_image.jpg' ); // Return an implementation that extends WP_Image_Editor

if ( ! is_wp_error( $image ) ) {
    $image->resize( 300, 300, true );
    $image->save( 'new_image.jpg' );
}

I don't know exactly if this will work but I'm sure if you look in the link I've gave you then you should be able to find it there.

Best of luck :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.