Project

General

Profile

Actions

Feature #41347

closed

ImageViewHelper: more flexible arguments

Added by Thomas Luzat about 12 years ago. Updated over 7 years ago.

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

0%

Estimated time:
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.


Files

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

Updated by Ingo Pfennigstorf about 12 years ago

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

Actions #2

Updated by Thomas Luzat about 12 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).

Actions #3

Updated by Ingo Pfennigstorf about 12 years ago

  • Status changed from New to Accepted
  • Target version set to 1910
Actions #4

Updated by Anja Leichsenring almost 12 years ago

  • Project changed from 534 to 2559
  • Category changed from 963 to Fluid: ViewHelpers
  • Target version deleted (1910)
Actions #5

Updated by Gerrit Code Review over 11 years ago

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

Actions #6

Updated by Thomas Luzat over 11 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".

Actions #7

Updated by Gerrit Code Review over 11 years ago

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

Actions #8

Updated by Sven Tappert over 10 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.

Actions #9

Updated by Simon Schaufelberger over 10 years ago

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

Actions #10

Updated by Gerrit Code Review over 10 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

Actions #11

Updated by Gerrit Code Review over 10 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

Actions #12

Updated by Alexander Opitz about 10 years ago

  • Project changed from 2559 to TYPO3 Core
  • Category changed from Fluid: ViewHelpers to Fluid
Actions #13

Updated by Wouter Wolters over 9 years ago

  • Status changed from Under Review to Closed

Will not be integrated in the core.

Actions #14

Updated by Felix Nagel over 9 years ago

Can we get a reason?

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

Actions #15

Updated by Thomas Luzat over 9 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 #.

Actions #16

Updated by Rafal Brzeski over 7 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/

Actions

Also available in: Atom PDF