Feature #41347

ImageViewHelper: more flexible arguments

Added by Thomas Luzat over 6 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2012-09-25
Due date:
% Done:

0%

PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Many features of getImgResource are currently not available through the view helper. It is unlikely that all functionality can easily be offered. I propose to at least allow passing arbitrary arguments as done with the attached patch. Usage example which converts an image to grayscale and adjusts its brightness:

<f:image src="{image}" alt="" params="{ params: '-level 0%,100%,5.0 -colorspace Gray' }" />

One may consider limiting the implementation to only allow passing ImageMagick params, which would be fine for my use case and would lead to:

<f:image src="{image}" alt="" params="-level 0%,100%,5.0 -colorspace Gray" />

This would obviously disallow passing other additional arguments to getImgResource.

ImageViewHelper.php.patch View - ImageViewHelper patch (1.1 KB) Thomas Luzat, 2012-09-25 12:56

History

#1 Updated by Ingo Pfennigstorf over 6 years ago

Quite a lot new parameters, what about passing them as single parameter with an array?

#2 Updated by Thomas Luzat over 6 years ago

Ingo Pfennigstorf wrote:

Quite a lot new parameters, what about passing them as single parameter with an array?

I can't see how this are quite a lot of parameters. The patch is just adding one single tag "params" (as used in the first usage example). My usage example might look confusing because the additional parameter passed to getImgResource in this example is named "params", too.

A more limiting implementation (which does not allow passing other arguments than "params" merged into the second parameter of getImgResource) would lead to a somewhat simpler syntax given in the second example:

<f:image src="{image}" alt="" params="-level 0%,100%,5.0 -colorspace Gray" />

This may be preferable if one cannot think of other use cases for this extension. A different implementation could also use an array:

<f:image src="{image}" alt="" params="{ '-level', '0%,100%,5.0', '-colorspace', 'Gray'}" />

This is complicated to type and there are probably few use cases where this is advantageous. As such I propose to implement either of the first two options (with my patch implementing the first option).

#3 Updated by Ingo Pfennigstorf over 6 years ago

  • Status changed from New to Accepted
  • Target version set to 1910

#4 Updated by Anja Leichsenring over 6 years ago

  • Project changed from Extbase MVC Framework to Fluid
  • Category changed from 963 to Fluid: ViewHelpers
  • Target version deleted (1910)

#5 Updated by Gerrit Code Review almost 6 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21161

#6 Updated by Thomas Luzat almost 6 years ago

Gerrit Code Review wrote:

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21161

This patch set implements the more limiting option mentioned above (because of better usability) with "params" being replaced by "parameters".

#7 Updated by Gerrit Code Review almost 6 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21162

#8 Updated by Sven Tappert about 5 years ago

Thomas, very nice idea.

It looks as if the ImageViewHelper has changed in the meantime (6.2.0beta6), so the key in the configuration array in the render() method now has to be 'additionalParameters' instead of 'params'. Otherwise it will not be recognized by the crop-scale-mask processing.

I implemented a custom ImageViewHelper, since it seems to take a while until this becomes part of the standard view helper.

#9 Updated by Simon Schaufelberger almost 5 years ago

this patch is actually really cool, i also want to see that in the core!

#10 Updated by Gerrit Code Review almost 5 years ago

  • Status changed from Accepted to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/21162

#11 Updated by Gerrit Code Review almost 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/21162

#12 Updated by Alexander Opitz over 4 years ago

  • Project changed from Fluid to TYPO3 Core
  • Category changed from Fluid: ViewHelpers to Fluid

#13 Updated by Wouter Wolters about 4 years ago

  • Status changed from Under Review to Closed

Will not be integrated in the core.

#14 Updated by Felix Nagel almost 4 years ago

Can we get a reason?

By the way: closing an issue with an existing patch without a reason is just rude.

#15 Updated by Thomas Luzat almost 4 years ago

There have been some comments within the patch sets.

Even if not wanted in core, the view helper should probably be extendable to (at least) allow modifying arguments instead of having to copy and patch the code. IIRC that is/was not possible, but I am too lazy to check or try further contributions.

The lack of speed when handling issues alone is too much of a hassle to get involved, but that should get a different issue #.

#16 Updated by Rafal Brzeski about 2 years ago

If you want to have special effects on images you can use CSS property today,
just use simple CSS Filters, with pretty nice browsers support today http://caniuse.com/#feat=css-filters

Examples:

http://www.cssreflex.com/css-generators/filter/
https://css-tricks.com/almanac/properties/f/filter/

Also available in: Atom PDF