Needs work
Project:
Drupal core
Version:
main
Component:
image.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Aug 2010 at 03:18 UTC
Updated:
23 Apr 2019 at 18:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
effulgentsia commentedThis patch adds the "upscale" option and defaults it to TRUE. This way, we retain BC with current HEAD, and don't need an update function to set it to TRUE for existing effects in the database. Plus, since modules can implement hook_image_default_styles(), we don't want to break their behavior (i.e., they should be able to leave 'upscale' unspecified, and it should then default to TRUE).
Yeah, it kind of sucks for it default to FALSE in the "scale" effect and default to TRUE in the "scale and crop" effect, but that's the price we have to pay to not break BC. I still think it's better to at least have the option rather than not.
Comment #2
effulgentsia commentedDries or webchick will probably be tempted to bump this to D8. Especially if that happens, but even if this patch lands, we need #875326: Add hook_image_effect_info_alter() to allow contrib modules to fill in any remaining holes.
Comment #3
ksenzeeI see no reason this should wait for D8. Yes, it's a minor WTF to have the defaults for the two effects be different, but I agree it's worth it to maintain BC with current HEAD at this point in the cycle. On the other hand, it's a real WTF to be forced into upscaling an image, especially since upscaling is rarely what you want anyway. So I do think the patch is needed. It's working beautifully on Drupal Gardens, btw.
Grammar nitpicks follow:
Comma should be a semicolon here. (I know this is copy/paste from another form's docblock; probably it should be changed as well.)
One too many nots.
s/Upscaling/upscaling (to preserve Dries's sanity).
Powered by Dreditor.
Comment #4
David_Rothstein commentedThis patch changes the UI, so I'm giving it the "string freeze" tag. Not sure if it still has any chance for D7 or not.
Comment #5
joeyabbs commentedsubscribing
Comment #6
ksenzeeI'm rerolling this with the doc changes I suggested above, and moving it to D8. It seems like a backport candidate though since it's BC.
Comment #7
ksenzeeOops, with patch this time.
Comment #8
ksenzeeI missed a documentation hunk, and a spelling error, in the last reroll. Try this instead.
BTW, I have tested this, and it still works.
Comment #9
effulgentsia commentedReroll to chase HEAD.
Comment #10
xjmAh, this drives me nuts! +1
Tagging as novice for the task of rerolling the Drupal 8.x patch on account of #22336: Move all core Drupal files under a /core folder to improve usability and upgrades.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #11
michaelfavia commentedReroll for d7 core move.
Comment #12
oriol_e9gD8, some cleanup and firsts steps to add upscale testing.
We still need more tests. Temporally NR for testbot.
Comment #13
oriol_e9gComment #14
alexiswatson commentedTo clarify, for images smaller than the specified dimensions that do not have the same aspect ratio (say, Resize and Crop 400x300, source image is 160x90), is the correct behavior to not scale while still cropping to the aspect ratio, or to neither scale nor crop and leave the original image intact?
Leaving the original intact seems the most intuitive when upscaling is turned off, as the image is still constrained within the given dimensions, though I'm curious as to what others think.
Comment #15
aendra commented@davidwatson -- it doesn't scale but does crop when not upscaling. I tend to agree with you, or at least that there should be an option not to crop when image isn't scaled.
Just applied Michaelfavia's patch in #11, seems to be working well with my D7 install.
Comment #16
coderintherye commentedWhat more tests are needed to make this needs review?
Comment #17
xjm@coderintherye, it needs automated tests that assert the feature works as expected. The patch includes one additional unit test assertion, but it would be good to add some more coverage to confirm that the feature works through the UI and various dimensions behave as expected. You can look in the existing image module tests to get an idea how other features are tested.
Comment #18
iflista commentedPatch from #12 doesn't apply to Drupal 8. It's broken. Tried both methods.
Will try to recreate it manually
It shows following:
Comment #19
iflista commentedRebuilded manually for drupal 8 with test.
Comment #20
iflista commentedComment #21
yesct commented#19: image-upscale-optional-with-test-872206-19.patch queued for re-testing.
Comment #22
yesct commented#19: image-upscale-optional-with-test-872206-19.patch queued for re-testing.
Comment #23
oriol_e9gMinor:
Should be:
Comment #24
rootworkMade the minor change from #23.
Comment #25
rootworkTagging this as work done during the global sprint.
Comment #26
eojthebraveThis should have a period at the end of the sentence.
I think the whitespace inserted between the text returned by resize summary and 'upscaling allowed' should be contained in the if statement so that it's not present if upscaling is off.
So change this line to something like the following:
return theme('image_resize_summary', array('data' => $data)) . ($data['upscale'] ? ' (' . t('upscaling allowed') . ')' : '');
Do we need to indicate that this is optional and can be left out, and will be defaulted to TRUE if omitted?
Super picky, but there are a handful of these that I think should be abbreviated to:
$data['upscale'] = !isset($data['upscale']) : TRUE : FALSE;
And as per #17 this still needs functional tests.
Powered by Dreditor.
Comment #27
kevin morse commentedI'm quite confused as I think all of this code has already made it into D8. Please confirm what actually needs to be done. Maybe just the backport?
Comment #28
thomas.fleming commentedThis has not made it into D8 yet as far as I can see.
Comment #29
claudiu.cristea@tidrif, the patch from #24 is against D8 but is obsolete. The codebase of D8 had dramatically changed since then.
Comment #30
chakrapani commentedClaudiu.cristea, yes the patch #24 is 10 months old and D8 has changed a lot since then. And the patch has not been added to D8.
I am working on creating a patch against the latest D8.
Comment #31
chakrapani commentedAdding a reroll as per the latest D8 snapshot.
Comment #32
alexiswatson commentedIf this hasn't made it into Drupal 8 yet, it's unfortunately not going to (see https://drupal.org/core/release-cycle).
Comment #33
webchickActually, it looks like that page is out of date as of #2135189: Proposal to manage the Drupal core release cycle. We will continue to ship new features like this in "minor" releases of Drupal 8.
Comment #34
skipyT commentedWhy do we do this? If the scale is bigger than 1, i think we should return TRUE without modifying the image.
Comment #35
claudiu.cristeaIf is optional add the default to documentation. Add "Defaults to TRUE." at the end.
You need to add the type of param.
This seems wrong. Maybe you wanted:
Remove trailing spaces.
Comment #36
skipyT commentedHi,
I modified the patch from #31. Removed the trailing spaces, modified the dimensions calculations, I modified the render summary to be french language compliant (we need the parenthesis in the translatable text) and fixed the other issues mentioned in #35.
Comment #37
skipyT commentedforgot to change the status
Comment #39
chakrapani commentedThe earlier patch seems to have failed some tests. I have made the following changes to the patch from #31:
This was missing in all of the earlier patches inturn causing an issue where the dimensions in the html image tag were different from the image displayed.
Comment #40
skipyT commentedHi,
Did you run the Unit tests also? I'm working on this patch from the morning and I can't get some unit tests working. Are you available on IRC to talk about this?
Comment #42
chakrapani commented39: image-upscale-optional-with-test-872206-39.patch queued for re-testing.
Comment #43
skipyT commentedI think it would be better to use my patch from #37, cause it is failing only in Imagetest unit tests. you don't resolve anything if you mark queue again the same patch file for re-testing.
I'm online on IRC #drupal-contribute if you want to discuss about your patch or we can discuss here also.
Comment #44
chakrapani commentedHi skipyT,
I have queued for re-testing because, it failed because of some memory issue which might not be because of the patch.
and yes I ran the unit tests as well.
I am available on irc for another 30 mins..lets discuss..
my irc nick is : _rcp
Comment #45
mathes commentedi tested patch from #39 and it works for me
Comment #46
chakrapani commentedmathes, thanks for testing.
the patch in #39 passed the test as well. hope someone can review and mark it RTBC or commit if everything is fine.
Comment #48
skipyT commentedIs this ok? I think if the configuration is empty we shoudn't display the (upscaling allowed) text.
The others parts are ok for me.
Comment #49
chakrapani commentedYes,
the default is true i.e when upscale is not set/defined it falls back to default which is TRUE in our case. this is the same logic we have implemented/used for the main scaleandcrop feature as well.
Comment #50
skipyT commentedI just checked the theme functions for the other effects and the theme_image_crop_summary is just calling the theme_resize_summary, perhaps we shall do the same for scale and crop, to call the scale summary to avoid code duplication. what do you think?
Comment #51
chakrapani commentedHi skipyT, thank you for the review.
yes, we can do that and call theme_image_scale_summary but that inturn calls theme_image_resize_summary i.e one more additional function call. I'm not sure which is better. So adding patches with both the cases.
And I've tested #48 again. Even though the code/logic is correct, we do not need to do it because 'upscale' will be set always in configurations as we have already handled the default configuration for upscale.
872206-51.patch :
872206-51-a.patch :
51.patch vrs 51-a.patch : which one to use ?
The theme function 'theme_image_scale_and_crop_summary' calls 'theme_image_resize_summary' + (add upscale text if applicable) , which is same as what function 'theme_image_scale_summary' does.
Use 51-a.patch if additional function call is better than duplicate code(1 line). Otherwise use 51.patch
interdiff-872206-51-51-a.txt gives the diff between 51.patch and 51-a.patch.
I think, we have covered all possible glitches now :)
Comment #52
skipyT commentedI definitively like the 51-a patch, I tested it and it seems ok, marked as RTBC.
Comment #53
alexiswatson commented@33: I stand corrected. :] Should we create a new issue to update those docs? Unless my memory/understanding fails me, point releases weren't used for new minor features in the past, which may be a source of confusion for those not in the know.
Comment #54
chakrapani commented51: image-upscale-optional-with-test-872206-51-a.patch queued for re-testing.
Comment #55
chakrapani commentedBeen in RTBC for more than 4 weeks.
Comment #57
vastav commented51: image-upscale-optional-with-test-872206-51-a.patch queued for re-testing.
Comment #58
vastav commentedstill green.
Comment #59
yesct commentedreviewing 51a since that is the one seems preferred here.
--
this is the only change in this file.
this standards fix is out of scope of this issue.
taking out.
(if we want to do it, we would in another patch that had to change those lines anyway, or in something like #1518116: [meta] Make Core pass Coder Review, #1533246: Make image module pass Coder Review)
doh! this was actually taking out the space that is standard according to
https://drupal.org/node/608152#indenting
anyway reverting this out of scope and incorrect change.
a while ago we go into a habit of being very verbose with param descriptions, repeating information that was in the function definition.
The docs requirements examples were corrected in https://drupal.org/node/1354#param
"Optional parameters are indicated by (optional); include information about the default value only if it is not obvious from the function signature."
fixed.
this change is out of scope of this issue.
reverted.
If this change were to be made, it would be because we had to change this line to make this patch function correctly, or as part of #1326608: Clean up API docs for image module. no that was too many little clean ups. I think we have something about correctly type hints and @param types. ... ok. I cant find such and issue, we could ping @jhodgdon to find out, or assume it is not appropriate right now, and we are just correcting this type of thing when we are in issue that already have to fix such lines for other reasons. Assuming we dont have a dedicated type hint @param related issue. Let's not do this unrelated change here.)
heh. for example, here.
this line is *added* by this patch.
we should add it correctly, with the type in the param and the function declaration.
fixed.
hm. function theme_....()
are we still adding theme_ functions?
searched to find:
#1757550: [Meta] Convert core theme functions to Twig templates
I think this addition of theme_ is ok.
but we should note that #1898420: image.module - Convert theme_ functions to Twig would need a reroll if this were committed first, or this would need a reroll if the other were committed.
adding it as a related issue.
nit (would not mark needs work for this on it's own, but since there are other core gates, fixing)
this is > than 80 chars.
"Lines containing comments (including docblocks) must wrap as close to 80 characters as possible without going over, "
https://drupal.org/node/1354#drupal
these is the only changes to tests.
seems like we need more here.
--
summary, tagging needs tests. we at least need a close look at what we might be able to test here from someone more familiar with tests involving image effects.
should be needs work for that.
this could also use an issue summary update and before and after pictures of the UI changes. tagging.
Comment #60
tomreavley commentedComment #61
tomreavley commentedBefore screenshots attached (included screenshot of Scale showing the "Allow upscaling" option that's missing from Scale and Crop).
Comment #62
tomreavley commentedPatch does not apply.
Comment #63
amitgoyal commentedAs mentioned in #62, patch in #59 no longer applies.
Please review updated patch which applies cleanly.
Comment #64
mondrake'images', not 'files'
After image module conversion to Twig, we should not really be introducing new theme_*() functions. Please convert this to a Twig template, or maybe reuse the existing image-scale-summary.html.twig one?
same here, use a 'template' key intead of a 'file' one. See existing examples.
Let's make this aligned with other effects, i.e. add the parent::getSummary, like (from ScaleImageEffect)
Note that this will impact #2073759: Convert toolkit operations to plugins which IMHO has a priority now.
Tests are adjusted so I am removing the 'Needs tests' tag.
Comment #65
l0keReworked patch.
Comment #66
m1r1k commentedComment #67
Jalandhar commentedPatch no longer applies. It needs reroll.
Comment #68
Jalandhar commentedHere is the updated patch which fixes this feature.
Comment #70
Jalandhar commentedUpdating the patch with the reroll changes.
Comment #72
xjmNote that this issue is filed as a feature request, so it is bound by issue thresholds. We currently have 100 criticals and 640 majors.
@alexpott pointed out that the patch in #70 includes some out-of-scope changes in
node.api.php.Comment #73
rootworkRerolled the patch and removed the changes to node.api.php.
Comment #75
rootworkWorking on other things at the sprint for now, if anyone else wants to take a crack at this.
Comment #76
xjmAs a feature request, per the beta changes policy, this is an 8.1.x issue now. Sorry little patch. :(
Comment #78
xjmThis can be active against the future development minor (currently 8.2.x).
Comment #79
johnrosswvsu commentedHi,
Ran this against 8.2.x (but patch still applies to 8.1.x) based from the last patch by @rootwork with a few variation.
Variations:
Set upscale to FALSE by default.
Uses 1 instead of TRUE for upscaling testing. This is for uniformity sake as seen in scale effect.
Removed template in hook_theme for style summary.
Adding actual template file.
And other small variations.
I replicated scale and crop for the 'defaults' and other stuffs.
Thanks.
Comment #80
johnrosswvsu commentedComment #81
johnrosswvsu commentedI will make further updates to address issues.
Comment #83
johnrosswvsu commentedComment #84
johnrosswvsu commentedThis is an update against:
https://www.drupal.org/node/872206#comment-10931269 && https://www.drupal.org/pift-ci-job/200361
Comment #86
johnrosswvsu commentedI am not entirely sure how to address the remaining test that fails:
07:36:48 Drupal\KernelTests\Core\Theme\StableTemplateOverrideTest 0 passes 1 fails
Will need help from anyone who has an idea to fix this.
Comment #87
johnrosswvsu commentedI guess I spoke too soon.
I updated against https://www.drupal.org/node/872206#comment-10931367 and added a theme override for image-scale-and-crop-summary.html.twig (new template to accommodate requirement of this ticket) in the core 'stable' theme.
Comment #89
joelpittetThis needs a re-roll as the patch no longer applies. Sorry this is a bit long in the tooth(old), but seems like it could be tackled at the sprint.
Comment #90
MobliMic commentedHi i'm at drupal con dublin. I'm looking at rerolling this now
Comment #91
MobliMic commentedRerolled patch on 8.3.x
Fixed merge conflict in migrate test
Please review
Comment #92
zeip commentedRemoving the reroll tag as that's been taken care of.
Comment #93
l0keLast patch doesn't really respect $upscale setting:
Dimensions would be set anyway, even if image wasn't upscaled. So I added condition that checks the result of
Image::scaleDimensions()function. This will guarantee that image with smaller dimensions will save original ones.Comment #94
br0kenIt would be more readable if you put every array item to its own line.
Also, what about to change old
arraysyntax to shorten?Do we need to have
isset()here?I guess method must return single type. Currently we have
NULLandboolean.Let's do not merge array in that way. Just save value of
parent::getSummary()into variable and override what you need.Comment #95
l0keChanged according to review notes.
Comment #96
l0keComment #97
br0kenComment #98
claudiu.cristeaStill needs:
And I'm adding "Needs change record".
Few comments...
Unrelated. Please revert them.
On optional params, we document the default value. At the end add: "Defaults to FALSE.".
More compact?
s/t()/$this->t()/
s/false/FALSE
I see no difference between the module based theme and the "stable" theme implementation. Then why we need this duplication? Just curious, because I'm not strong enough in theming :)
Comment #99
l0ke$summary['#data'] = $this->configuration;is redundant here.As for union I'd rather agree with @BR0kEN, no need to perform operation while we can omit it, event though it's shorter.
Comment #100
l0keComment #101
l0keComment #102
br0kenComment #103
l0keI've created Draft change record, please review https://www.drupal.org/node/2825390
Comment #104
br0kenIs it ready now? I guess. I'd love to have this in core.
Comment #105
claudiu.cristeaThank you. It starts to look good. However, some small changes are still required. The most important is that it needs an upgrade path to fix existing image styles that contain this effect with the default value.
s/array()/[]
This is useless. The parent is doing this already.
This needs an upgrade path. We need to update existing image style configurations that have 'scale and crop' effects by adding the default value (which is FALSE).
Comment #106
mondrakeLooking into the upgrade path - I need something similar for Image Effects, #2702205-16: Text overlay: add an hook to alter the overlaid text and use it to enable setting maximum number of characters displayed
Comment #107
mondrake#105:
1. done
2. done
3. I added an update function to refresh all image styles with the new 'upscale' parameter. I do not know how to write a test for that, though. @claudiu.cristea is there any example you can point to?
Unassigning.
Comment #108
claudiu.cristeaThis should not live here. This is more suitable for a post_update update because it uses the full API (ie it doesn't have to repair the database). See https://www.drupal.org/node/2563673.
See \Drupal\image\Tests\Update\ImageUpdateTest for a test example.
Comment #109
mondrakeComment #110
claudiu.cristeaI think the test can be added to \Drupal\image\Tests\Update\ImageUpdateTest because setDatabaseDumpFiles() would be the same.
Comment #111
mondrake#110: The shipped image styles, though, do not contain any 'Scale and crop' effects. We would need to add a test style with a 'Scale and crop' effect as it can be configured before this patch is applied, so that we can test the update function and ensure that it adds the 'upscale' parameter. How to do that?
Comment #112
claudiu.cristeaBad. Then you'll have to apply some fixtures to the shipped DB. See \Drupal\views\Tests\Update\BooleanFilterValuesUpdateTest::setDatabaseDumpFiles() for an example. Then you'll need to add the test in a new file/class. In the fixture file you'll need to add the effect on the lowest API level you can. If you use the image style API it will automatically add the default 'upscale', because it will use the current code API, but you don't want that. So probably you want to read a style directly from DB {config} table, add your effect (w/o upscale) and write it back in DB.
Comment #113
mondrakeOnly moved the update from
image.installtoimage.post_update.php, as per #108.Update test missing, #112 looks tough...
Comment #114
mondrakeComment #115
br0ken@claudiu.cristea, I am not agree that we need to use short array syntax in exact place. Everywhere, in whole file,
array()used and we need to change them all or go ahead with old variant.Comment #116
claudiu.cristea@BR0kEN, there's no rule it should apply to whole file. The Drupal coding standards page states about short syntax:
So, not "whole file".
See: https://www.drupal.org/docs/develop/standards/coding-standards#array
Comment #117
br0ken@claudiu.cristea, not sure that this make sense. It looks strange when different parts of the same file uses different coding standards. Why not to create separate issue for this?
Comment #118
claudiu.cristea@BR0kEN because that is new code. If we touched that line and we can convert the array to the new syntax, by following the rules that I mentioned in #116, then we do it. If we only edit that line to convert the array then is out-of-scope. But we already touched that line to add
'upscale' => $upscale, so it's OK to change it.Comment #119
mondrakeGiving a try to upgrade path test, based on instructions in #112.
Comment #120
mondrakeSee this.
Comment #122
claudiu.cristeaLooks nice!
It's more about 'image': @group image
Comment #124
claudiu.cristeaWhen you use $image_style->getEffect(), the API will apply the defaults and 'upscale' will be added with the default. You should use the config system:
For the same reason, it should be possible that we skip this sequence and simply...
because, probably, the 'upscale' is automatically added with FALSE on load. To be tested!
EDIT: Should work:
Comment #125
mondrakeThanks @claudiu.cristea! Let's see what bot thinks.
Comment #126
claudiu.cristeaProbably this is unused now.
Comment #127
mondrake#126: indeed...
Comment #128
claudiu.cristeaLooks good to me.
Comment #129
l0keI would also simplyfy this.
If we have already changed this lines ten let's cast it to one style.
Assertion doesn't guarantee that
$effect_data['upscale']exists. It will raise a notice, let's avoid it.Comment #130
l0keSome more things.
Redundant newline
Oops, my bad mistake in fail message.
Comment #131
claudiu.cristea#129.1; Disagree with that. Now the line is too long. It's unreadable.
+1 for #129.2.
#129.3: Then:
Comment #132
br0ken@claudiu.cristea
$this->fail().Comment #133
claudiu.cristeaOK for 1.
This is an unusual way to assert that the key 'upscale' exists in an array. If we can use an assertion, why not using it?
Comment #134
br0ken@claudiu.cristea, it's unusual, I agree. But more safe for preventing PHP notice, when key will not be presented in array.
Comment #135
mondrake#134
we usually do not care about that in test code. If it fails, it fails. Also, $this->fail() with a message is kind of obsolete as we are trying to remove, in general, assertion messages from tests that are being more and more migrated to phpunit. I still prefer
it's more readable. If the first fails the assertion then we are already facing a failed test, then why caring if the second raises a notice?
Comment #136
br0ken@mondrake, I was 100% sure that someone will affect a theme regarding notices/warning/exceptions etc. in test code and tell that we may ignore them. But I think better to have fails/passes instead of them. If we can omit language-level warnings and having tools to do this, why we have to choose other way?
Comment #137
l0keNot so unusual way of assertion, actually. Quite similar lines can be found in
core/modules/image/src/Tests/ImageStylesPathAndUrlTest.phpAnd, yes - if we can prevent notice in such a simple way, why not to do this?
Comment #138
mondrake@BR0kEN, @l0ke, so let's agree we disagree :)
Moving back to RTBC, let's not hold the entire patch on such a minor point, and see the opinion of a core committer.
Comment #139
claudiu.cristeaNo, you cannot RTBC as you have contributed to the code. The test failures should not be fancy. The tests should be easy to read and understand. For this reason we have assertions and we are not using conditions that are calling pass() or fail().
So this should be reverted acording to #135 or #131. Note that in #131, assertTrue() returns a boolean, avoiding the notice. But I still stand with #135.
Comment #140
l0ke@ claudiu.cristea ok, as something in the middle of our point of view, do you think variant from #131 would be good enough for RTBC?
Comment #141
claudiu.cristeaComment #143
claudiu.cristeaLooks like an unrelated failure.
Comment #145
claudiu.cristeaI opened this #2828045: Tests failing with unrelated „Translation: The French translation is not available”.
Comment #147
claudiu.cristeaComment #148
claudiu.cristeaComment #149
l0keComment #151
br0kenComment #152
catchWe don't allow adding parameters to interfaces usually because it would break any direct implementations of the interface.
So there's two ways to deal with this:
1. If we're very confident that no-one is directly implementing ImageInterface and would only subclass Image, then it could be done in a minor as @internal - but this isn't a bug fix and Image isn't a base class, so not sure that'll work.
2. Create a new interface with a new method (scaleAndCropUpscale()?scaleCrop()?) extending from ImageInterface then have image implement the new interface.
Moving back to CNR for now. Didn't do a full review of the rest of the patch yet.
Comment #153
mondrake#152: do we need such a new method at all? After long discussion, these methods on ImageInterface were introduced in #2073759: Convert toolkit operations to plugins:
in order to keep some sort of backwards compatibility. But we could call in the effect
instead of
and avoid the need to change interface or add more methods.
BTW - is the patch actually doing what is meant to do? I do not see any change to the GD toolkit that would somehow manage the newly introduced 'upscale' argument. Needs manual testing I guess.
Comment #154
l0ke#152
1. #153 makes sense
2. Looks a bit odd and overcomplicated
#153
Patch is doing what is has do and it was tested. No need to make any changes in GD, this option already exists, see example in
Drupal\image\Plugin\ImageEffect\ScaleImageEffectJust did the same in
ScaleAndCropImageEffectComment #155
mondrake#154: then, why do we need to pass the 'upscale' parameter to the ImageToolkitOperation if that is not used?
Comment #156
br0ken@mondrake, do not change the status of issue during the discussion. Parameter is used, check
\Drupal\Component\Utility\Image::scaleDimensions().Comment #157
br0ken@l0ke,
I propose to reformat this method:
Do we need this update? Note, that
Image::scaleDimensions()above will do the same if upscale will be allowed.Comment #158
l0ke#157
Thing is
Image::scaleDimensions()saves an aspect ratio of an original image. And this update is actually how "crop" performed. Without this image will not be cropped to precise dimesions.I'm also thinking now that this changes probably shouldn't take place. Skipping one dimension allowed in "Scale" to make second one auto, in the context of "Scale and crop" it dosen't seem to make sense. Any other thoughts about this point?
Comment #159
darius.restivan commentedTested both upscaled and normal images. Works well.
Comment #160
darius.restivan commentedTested both the normal and upscaled images and it works well.
Comment #161
catchWe still need to deal with the discussion from #152 onwards before this can be committed.
Comment #168
bkosborneCouple comments:
1) RE #158, agreed, we should not make width or height optional. Both should be required because crop needs to know the specific size. I think that part of the patch should be removed.
2) If an undersized image is uploaded (it's height and/or width are smaller than the defined height/width for the crop), what is the expected behavior when upscaling is disabled? This was mentioned many years ago in #14. My expected behavior is that the image is still cropped to the desired aspect ratio (calculated using the width/height of the desired crop size). Not sure if GD does that by default, but if it doesn't, then we need some logic to make that happen.
3) I think we need to update the arguments() method of \Drupal\system\Plugin\ImageToolkit\Operation\gd\ScaleAndCrop.php to add the new argument for upscale, just so it's documented.
Comment #169
bkosborneFor anyone that needs this support in the meantime, here's a contrib module I just created that adds it: https://www.drupal.org/project/image_scale_and_crop_without_upscale
Comment #170
markabur commentedWhen I specify a crop, it's because I want the image to be a specific size. If the image is too small to be that size, then I wouldn't want it cropped at all -- that would make the image even smaller, which to me makes the problem worse. My clients would get confused by that behavior.
For example, if I have a 1920x1080 space and the client uploads a 1080x1080 image, I'd leave the image alone and let there be black bars on the sides. I don't see any benefit to cropping the top and bottom off the image when it was big enough to fill the space vertically to begin with.
Comment #171
bkosborneThe benefit is that you may not want black bars to show up on your site.
Comment #172
markabur commentedIf the image is too small and you absolutely need to fill all of the space anyway, then just use the Scale and Crop option as-is, since it upsamples to fit.