• Hey, this may be obvious to any longtime WP users, but I’m wondering if there is a way to stop WP from cropping images and have it SHRINK them to fit the sizes it auto-generates. Just don’t want the pictures to be chopped off heads and the like.

    • This topic was modified 1 year, 5 months ago by darkflux.
Viewing 5 replies - 1 through 5 (of 5 total)
  • How the images are cropped is (mostly) up to your themes settings.

    The majority of times, image sizes are set by the theme, and that includes if they are cropped or not. Some themes have settings for this, and some don’t.

    If your theme doesn’t have that you might be able to set up your own image sizes and set a filter up to display those instead – assuming that your theme has a filter available that will let you change the image size for the areas that you want to change.

    Thread Starter darkflux

    (@darkflux)

    @bbast2 not talking about the import photo settings you SEE when you add one. I’m talking about the “behind the scenes” cropping that is done.

    @catacaustic That is DEFINITELY integrated into the theme I am using. What I am asking is, where is that typically located, or what does the code look like? I’ve browsed thru the functions files, and don’t see anything related to it there.

    I’m okay with looking for a needle in a haystack, but when I don’t know what the needle LOOKS like, let alone which haystack it is in, it is a little beyond me to try to read thru all the code for the theme…

    • This reply was modified 1 year, 5 months ago by darkflux.

    There’s nowhere that the code is “typically located”, but it is most likely somewhere like the themes functions.php file, or in some other PHP files or classes. Some themes also have admin pages that let you adjust image sizes, so that’s also a possibility. Without knowing the theme there’s no possible way of saying.

    As far as code goes, it’s normally done by a call to the add_image_size() function, again somewhere in your themes code. If you can find that, you can probably work backwards from there to find out what’s happening.

    Thread Starter darkflux

    (@darkflux)

    Hmm…okay. Thank you for your help.

    I wish WordPress had an easier way of searching through code. I like their numbering on the sides of lines, which helps with errors, but in the OLD interface I used to be able to “Find in page”, but NOW (since Gutenberg) Find only finds things that are on-screen, which is less than helpful when you have a Theme-Functions.php that is 2000+ lines. By the way, the theme is Gridbone, but I don’t expect you to sift through it to find something for me. I will just have to earn my paycheck, lol.

    Thanks again!

    I looked at that theme, and it’s surprisingly easy to find. The code is in the theme-functions.php file, and it’s only at line 77 to 81, so right at the top of the file.

    The bad news is that there’s no filters set up in the theme for image sizes, so what they’ve set is what’s set.

    The good news is that you can set up a child theme, or a custom plugin, that can over-ride those settings. As long as you set up your action call with a priority of 11 or higher, you can remove sizes and add in your own.

    Something (just typed in here, not tested) like this:

    function change_image_sizes() {
        add_image_size( 'gridbone-480w-480h-image', 480, 480, false );
        // Etc for all image sizes as needed...
    }
    
    add_action ('after_setup_theme', 'chamge_image_sizes', 11);

    After that, run a plugin that will re-do the thumbnails (I use Regenerate Thumbnails for this).

    Just remember that you might get inconsistent results in your theme if the images are meant to be square, but end up being portrait or landscape, and this can very easily make your theme look weird.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Stop Image Cropping’ is closed to new replies.