Support » Theme: Twenty Nineteen » Limit Image Size?

  • Hi, is it possible to add some code to fucntions.php that would downsize all uploaded images to a single, certain width?

    I’m creating a multisite installation and I need to make sure that when someone uploads an image, that:

    1. If it is larger than 350px that it gets brought down to that width. (and that height is adjusted proportionally)
    2. If it is smaller than 350px, it’s left alone
    3. That only one size is generated on image upload. (not three)

    Because this is a multisite, I want to control it from the child theme’s functions.php rather than having to set the media options for each site in the multisite.

    Thanks for any help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • How are you allowing users/visitors to upload the image to your site? A form on the frontend?

    Thread Starter ironlion37


    They are uploading to posts via the “featured image” widget on the posts page. So, using the WordPress media uploader.

    I guess it should be something like this in functions.php
    add_image_size( 'custom-size', 350, 180 ); // 350 pixels wide by 180 pixels tall, soft proportional crop mode.

    In the child theme template add something like this

    if ( has_post_thumbnail() ) { 
        the_post_thumbnail( 'custom-size' ); 

    You can also check this link and this link for more maybe even better options.

    Thread Starter ironlion37


    Thanks Bianca. I don’t think that’s quite the solution I’m looking for though.

    The behavior I’m looking for is that when an image is uploaded via the media uploader, only one file is saved in /content/uploads and that file is 350px or less.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Limit Image Size?’ is closed to new replies.