SamC Posted January 27, 2018 Posted January 27, 2018 I'm still having some trouble getting my head around the image sizer options. I was going over this old thread (horsts reply in this case): ...which suggests not overriding them in case you miss out any key/value pairs. But then I was reading on the official docs (just after halfway down the page): https://processwire.com/api/fieldtypes/images/ Quote You may modify the default $options that your system uses by adding a $config->imageSizerOptions in your /site/config.php file: $config->imageSizerOptions = array( 'upscaling' => true, 'cropping' => true, 'quality' => 90, ); ...but a var_dump of $config->imageSizerOptions shows me this: array(7) { ["upscaling"]=> bool(true) ["cropping"]=> bool(true) ["autoRotation"]=> bool(true) ["sharpening"]=> string(4) "soft" ["quality"]=> int(90) ["hidpiQuality"]=> int(60) ["defaultGamma"]=> float(2) } So does setting default system values in config.php as above not also miss out some key/value pairs? Not sure why I'm having such a hard time with the image options, but I am! Any help is appreciated, thanks. =EDIT= Can I add I just put: $config->imageSizerOptions = array( 'upscaling' => true, 'cropping' => true, 'quality' => 10, ); ...in config.php. Now a var_dump of $config->imageSizerOptions shows me: array(3) { ["upscaling"]=> bool(true) ["cropping"]=> bool(true) ["quality"]=> int(10) } = EDIT = Back again. So did (in config.php): $config->customImageSizerOptions = array( 'upscaling' => true, 'cropping' => 'north', 'quality' => 10, ); $config->imageSizerOptions = array_merge($config->imageSizerOptions, $config->customImageSizerOptions); var_dump of $config->imageSizerOptions shows me: array(7) { ["upscaling"]=> bool(true) ["cropping"]=> string(6) "north" // YAY! ["autoRotation"]=> bool(true) ["sharpening"]=> string(4) "soft" ["quality"]=> int(10) // YAY! ["hidpiQuality"]=> int(60) ["defaultGamma"]=> float(2) }
bernhard Posted January 27, 2018 Posted January 27, 2018 [offtopic] you know that tracy has the bd() option to dump beautifully highlighted and collapsible variable dumps? Do you still have a question? I cannot really follow your --edit-- junks 1
SamC Posted January 27, 2018 Author Posted January 27, 2018 Lol yeah, ended up thinking out loud on that one... 1 hour ago, SamC said: You may modify the default $options that your system uses by adding a $config->imageSizerOptions in your /site/config.php file: $config->imageSizerOptions = array( 'upscaling' => true, 'cropping' => true, 'quality' => 90, ); This still puzzles me. Doing this (as I learned above) means a bunch of key/value pairs are missed out. I know I've been saying this for ages, but still got to get started using Tracy regularly.
rick Posted January 27, 2018 Posted January 27, 2018 10 minutes ago, SamC said: I know I've been saying this for ages, but still got to get started using Tracy regularly. Tracy is pretty powerful, and with that power comes a learning curve. I'm learning as I go and still have a long way to go. But you can't beat the convenience and ease of use (when you learn a feature) in debugging and testing code. [/offtopic]
iank Posted January 29, 2018 Posted January 29, 2018 I believe you can do it like this in your config.php on an individual option basis: $config->imageSizerOptions('quality', 10); $config->imageSizerOptions('cropping', 'north'); ..and so on; this doesn't override any of the other defaults. 1 1
SamC Posted January 29, 2018 Author Posted January 29, 2018 3 hours ago, iank said: I believe you can do it like this in your config.php on an individual option basis: $config->imageSizerOptions('quality', 10); $config->imageSizerOptions('cropping', 'north'); ..and so on; this doesn't override any of the other defaults. Nice tip! Thanks
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now