Feature #38782

Alias-support for image variants

Added by Adrian Föder about 3 years ago. Updated over 2 years ago.

Status:Resolved Start date:2012-07-09
Priority:Could have Due date:
Assigned To:Adrian Föder % Done:

0%

Category:-
Target version:-

Description

currently, the so-called "image variants" are not really meant to be reused because they are based on the hash of their "processing instructions".
This means, if an image variant should be used, the processing instruction has to be provided anyways, which make the presence of a variant be useful for the framework, but not useful for the developer.

Having talked with Bastian, we suggest introducing "image aliases" which can be introduced by the developer. Such an alias could be small, micro, default, micro_watermarked or so.

The method createImageVariant would be extended to accept an alias, i.e.

1    public function createImageVariant(array $processingInstructions) {
2        $uniqueHash = sha1($this->resource->getResourcePointer()->getHash() . '|' . serialize($processingInstructions));

will become
1 public function createImageVariant(array $processingInstructions, $alias = NULL) { 2 $uniqueHash = sha1($this->resource->getResourcePointer()->getHash() . '|' . $alias ?: serialize($processingInstructions));

additionally, there will be methods

1public function removeImageVariantByAlias($alias);
2
3public function getImageVariantByAlias($alias);
4

As an optional enhancement, I could imagine an extension of the getImageVariantByAlias that, if that alias does not exist, attempts to create an ImageVariant with the processingInstructions taken from the Settings.yaml. So this settings.yaml could look like

 1TYPO3:
 2  Media:
 3    ImageVariants:
 4      AliasPresetProcessingInstructions:
 5        'micro':
 6          command: thumbnail
 7          options:
 8            size:
 9              width: 16
10              height: 16
11            mode: %TYPO3\Media\Domain\Model\ImageInterface::RATIOMODE_INSET% //if that const accessing works
12

Associated revisions

Revision a9f5b765
Added by Adrian Föder over 2 years ago

[FEATURE] Provide alias handling for ImageVariants

Reusing of ImageVariants is now enhanced by providing alias names
for ImageVariants, for example "small" or "medium" etc.

Convient methods for handling with these aliases are provided, this
includes, for example, removing Variants by their alias.

An alias is simply created with passing an additional, optional
`alias` argument to the Image's createImageVariant() method.

Change-Id: I7e488a85968b4807f4b65015deb1d62e46485648
Related: #38782

History

#1 Updated by Adrian Föder almost 3 years ago

  • Tracker changed from Bug to Feature

#2 Updated by Adrian Föder almost 3 years ago

  • Status changed from New to Accepted

#3 Updated by Adrian Föder almost 3 years ago

  • Status changed from Accepted to Under Review

Change set for the basic Alias functionality: https://review.typo3.org/#/c/15030/1

#4 Updated by Adrian Föder over 2 years ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF