[mp_product_image] size and cropping problem

Hi there,

Right now I’m trying to customize the product blocks in terms of how they look and showing what information. But I’m having a problem with the shortcode mp_product_image, which doesn’t allow me to specific a separate width and separate height.

I tried to copy the mp_product_image function from template-functions.php and created a new function that takes different parameters like this:

function mp_product_image_singleWH( $echo = true, $context = ‘single’, $post_id = NULL, $width = NULL, $height = NULL ) …

and inside the function where it has the condition for $context = ‘single’, I have:

$size = array(intval($width), intval($height));

Then in the mp_list_global_products function, where it has the condition if ($show_thumbnail), I call this:

$thumbnail = mp_product_image_singleWH( false, $context, $product->post_id, 186, 144 );

But the image that shows is not cropped to exactly 186px width and 144px height. I have one image that’s 124px (w) X 144px (h), and the other image is 184px (w) X 122px (h). So I realize it kind of take one of the length and did not do an exact crop from the original image (which is way bigger than 186×144).

So does anyone know how to accomplish the exact cropping to the specific size I aforementioned?

Thank you so much and any help would be really appreciated!

  • JDJ
    • Flash Drive

    Hi There,

    Have you tried to go to Wp Settings >> media >> and tick the box next to “Crop thumbnail to exact dimensions (normally thumbnails are proportional)”

    regenerate your thumbnails or re-upload your images.

    in marketpress select thumbnail size in product listing…

    It works great for “thumbnails” but I would like to have the same functionality for the small size and medium size images ( ability to crop to exact dimensions) if anyone knows?? Thanks

  • littlemkv
    • Flash Drive

    Thank you so much JDJ!

    You really save me a lot of time and now the cropping works very well after I installed the Regenerate Thumbnails plugin.

    I used to install this for my previous projects but somehow forgot about using it on this one…

    Thank you!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.