Forums

Modify the crop position of the_post_thumbnail(); (2 posts)

  1. supergab
    Member
    Posted 9 months ago #

    Hello I would to modify the crop position of the_post_thumbnail();

    So I look in the wp-includes/media.php file and go to the image_resize_dimensions function and modify

    $s_x = floor( ($orig_w - $crop_w) / 2 );
    $s_y = floor( ($orig_h - $crop_h) / 2 );

    to

    $s_x = 0;
    $s_y = 0;

    in order to have the position to top of the picture.

    But I would like it top crop at 20% from the top. Can someone help me with the syntax?

    Many thanks for your time and help.

  2. Tanel
    Member
    Posted 8 months ago #

    A late reply, but maybe still handy.

    To get it to crop at around 20% from the top, replace the lower line with:

    $s_y = floor( ($orig_h - $crop_h) / 5 );

    You can actually fiddle around with the last number (5) to get the result you need.

Reply

You must log in to post.

About this Topic