Jump to content

Image cropping false not working


juhis
 Share

Recommended Posts

Hi,

I have set image cropping to false like this:

$options = array( 'upscaling' => true, 'cropping' => false, 'quality' => 90 ); <- this is from the cheatsheet

$thumb = $item->image->size(120, 50, $options);

...for some reason image gets cropped anyway. I'm using processwire 2.3.0. Does this work only if width or height is 0?

Link to comment
Share on other sites

@RJay: yes that's right, - but also it is right that if you want to keep proportions and want that they fit into max dimensions for width *and* height you can call:

size( $myMaxWidth, $myMaxHeight, array('cropping'=>false) );

For example: http://nogajski.de/priv/postings/rearrangedImageSizer.html#sizeNoCrop & http://nogajski.de/priv/postings/rearrangedImageSizer.html#sizeCrop

  • Like 3
Link to comment
Share on other sites

It seem's that maxwidth and maxheight need to be equal values like this: size( 100, 100, array('cropping'=>false) );

This is not working $item->image->size(120, 50, $options);

Hi J1312, but this must work too!

I haven't a 2.3 stable version installed here, only latest dev, so I cannot test. But it sounds not logical. What are the dimensions of the original image and what is the setting for upscaling?

Maybe a typo in $options, please use: size( 80, 90, array('cropping'=>false, 'upscaling'=>true) );

OH, blink-blink: you also should use removeVariations() first, while testing.

please use:

$image = $page->images->first();

if($image) {
    $image->removeVariations(); // otherwise it may take a previous cached version instead of create a new one
    echo "<img src='{$image->size( 80, 90, array('cropping'=>false, 'upscaling'=>true) )->url}' />";
}
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

I haven't a 2.3 stable version installed here, only latest dev, so I cannot test. But it sounds not logical. What are the dimensions of the original image and what is the setting for upscaling?

<aside>I have one main PW install for testing stuff. I have have two wire folders. named "stable-wire" and "wire". The former has, well, the stable version of PW and the one for my daily use has the "dev" version. If I need to test something in the stable version, I temporarily rename the folders. "stable-wire" becomes "wire" and "wire" becomes "dev-wire". I used to have two different installs but thought that didn't make sense since PW core is in the wire folder. :) Am doing this the "wrong" way? :D</aside>

Apologies for temporarily hijacking this thread :)

Link to comment
Share on other sites

<aside>I have one main PW install for testing stuff. I have have two wire folders. named "stable-wire" and "wire". The former has, well, the stable version of PW and the one for my daily use has the "dev" version. If I need to test something in the stable version, I temporarily rename the folders. "stable-wire" becomes "wire" and "wire" becomes "dev-wire". I used to have two different installs but thought that didn't make sense since PW core is in the wire folder.  :) Am doing this the "wrong" way?  :D</aside>

I think that's okay, but it could be problematic in some cases like when file locations are different between master and dev, or when dev is using an updated DB schema from master. I don't think that either is the case right now, but just something to watch out for. The safest bet is to run them on separate databases. In your current setup, worst case is probably that you could end up being only able to run dev (with some part of the DB schema not compatible with the older stable branch). The changing file locations is not so much of an issue, but if you get errors you might need to manually clear the Modules cache (i.e. remove all /site/assets/cache/Modules.* files). 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...