Support » Plugins » Crop from LEFT or RIGHT of image instead of just center

  • Resolved rk2oo9

    (@rk2oo9)


    Hey Guys,

    Just thought I’d post this in case anyone wants to do the same on their blog.

    By default, WP crops a thumbnail from the CENTER of the image. I am creating a Web Design gallery and generally the left hand side of my screenshots contain the important bits (logos etc). So i wanted my thumbnails to be cropped from the LEFT (not Center). Here is what i did (im using WP v2.7)

    1) Go to wp-includes/media.php

    2) Go to Line 288

    3) Replace this:

    $s_x = floor(($orig_w – $crop_w)/2);

    with this:

    //$s_x = floor(($orig_w – $crop_w)/2); 
    $s_x = 0;

    (Commenting out the old code in case you want to center again later).

    Using $s_x = 0; just means that it is cropped from the LEFT. Alternatively, you can use $s_x = $orig_w – $crop_w; to crop from RIGHT. Oh and you can follow the same methodology to crop from TOP or BOTTOM.

    Hope it helps.

    Cheers,

    RK

Viewing 2 replies - 1 through 2 (of 2 total)
  • I don’t think this applies to 2.8, as it didn’t work.

    Is there a way to do this from my theme’s functions.php?

    I don’t want to mess with the WordPress installation as I’d have to modify it every time a new version came out…

    It also seems more elegant to do it through options in the theme, rather than hack WP includes.

    Any help is greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Crop from LEFT or RIGHT of image instead of just center’ is closed to new replies.