-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: MaxWidth() & MaxHeight() for Image #4211
Comments
I like this a lot! +1 |
So Max methods use crop by default? I wonder if that could be made obvious in the method name? |
Yeah I was thinking about that too. Maybe should be $CropMaxWidth & $CropMaxHeight? That could actually allow us to introduce separate functions $MaxWidth and $MaxHeight that act like $SetWidth and $SetHeight with the difference that they don't allow up-sampling. Related: #4201 |
Hey @tractorcow what do you think of this outline? Instead of making any changes to existing functions as proposed in #4201, this would only add new functions so would be a safer approach and easier to understand what's going on when you implement them in templates. I can get a PR together pretty quickly if you think this could make it in to 3.2 :) New
|
Method | Description | Cropping / aspect ratio |
---|---|---|
ScaleMaxWidth( integer $width ) |
Proportionally scale down this image if it is wider than the specified width | None / Preserved |
ScaleMaxHeight( integer $height ) |
Proportionally scale down this image if it is taller than the specified height | None / Preserved |
ScaleMax( integer $width, integer $height ) |
Proportionally scale down this image if it is wider or taller than the specified dimensions | None / Preserved |
CropMaxWidth( integer $width ) |
Crop image if it exceeds specified width. Retain height. | Crop left and right sides if necessary |
CropMaxHeight( integer $height ) |
Crop image if it exceeds specified height. Retain width. | Crop top and bottom if necessary |
CropMax( integer $width, integer $height ) |
Crop this image to the aspect ratio defined by specified width and height. Down-sample to specified dimensions if necessary (don't up-sample). | Crop on X or Y axis as necessary |
Sounds good to me. Make the PR and cc me. :D Please include docs and I'll get it merged into 3.2 |
Added ability to scale and crop images while ensuring upsampling does not occur. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur. Also brought Image docs up to date. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur. Also brought Image docs up to date. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur. Also brought Image docs up to date. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur. Also brought Image docs up to date. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur. Also brought Image docs up to date. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur. Also brought Image docs up to date. Closes silverstripe#3532, closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur, and brought Image docs up to date. Closes silverstripe#4211
Added ability to scale and crop images while ensuring upsampling does not occur, and brought Image docs up to date. Closes silverstripe#4211
Renamed image functions with more expressive names. Added CropWidth & CropHeight functions. Added no-upsampling capabilities. Cleaned up Image docs. Closes silverstripe#4211
Renamed image functions with more expressive names. Added CropWidth & CropHeight functions. Added no-upsampling capabilities. Cleaned up Image docs. Closes silverstripe#4211
Merged with #4229 |
I whipped up a quick extension for a forum post and thought it might be a useful addition to core. Whaddya think? Should I submit a PR?
The text was updated successfully, but these errors were encountered: