Documentation · ViewHelper reference

Uri / ImageViewHelper


Resizes a given image (if required) and returns its relative path.

Examples

Default

<f:uri.image src="EXT:myext/Resources/Public/typo3_logo.png" />

Output

typo3conf/ext/myext/Resources/Public/typo3_logo.png
or (in BE mode): ../typo3conf/ext/myext/Resources/Public/typo3_logo.png

Image Object

<f:uri.image image="{imageObject}" />

Output

fileadmin/images/image.png
or (in BE mode):
fileadmin/images/image.png

Inline notation

{f:uri.image(src: 'EXT:myext/Resources/Public/typo3_logo.png', minWidth: 30, maxWidth: 40)}

Output

typo3temp/pics/[b4c0e7ed5c].png
(depending on your TYPO3s encryption key)

non existing image

<f:uri.image src="NonExistingImage.png" />

Output

Could not get image resource for "NonExistingImage.png".

/
  • Tag usage example

    <f:uri.image src="NULL" image="[anySimpleType]" width="NULL" height="NULL" minWidth="123" minHeight="123" maxWidth="123" maxHeight="123" treatIdAsReference="1" crop="[anySimpleType]" absolute="1">
    	<!-- tag content - may be ignored! -->
    </f:uri.image>
  • Inline usage example

    {f:uri.image(src: 'NULL', image: [anySimpleType], width: 'NULL', height: 'NULL', minWidth: 123, minHeight: 123, maxWidth: 123, maxHeight: 123, treatIdAsReference: 1, crop: [anySimpleType], absolute: 1)}

Arguments

Argument Description Type
absolute

Force absolute URL

boolean
crop

overrule cropping of image (setting to FALSE disables the cropping set in FileReference)

anySimpleType
height

height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.

string
image anySimpleType
maxHeight

maximum height of the image

integer
maxWidth

maximum width of the image

integer
minHeight

minimum height of the image

integer
minWidth

minimum width of the image

integer
src string
treatIdAsReference

given src argument is a sysfilereference record

boolean
width

width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.

string
Required attribute

Revision history

commit 06b0d9efdad98af4c5b13dce887ee9f32e089752
Author: Bastian Waidelich <*****@typo3.org>
Date:   Thu Jun 24 10:14:25 2010 +0000

    [+FEATURE] Fluid (ViewHelpers): Added uri.image ViewHelper. This resolves #8233
    [+FEATURE] Fluid (ViewHelpers): Added URI options noCache, noCacheHash, section, format, additionalParams, absolute, addQueryString & argumentsToBeExcludedFromQueryString to FormViewHelper. Resolves #8247
    [+BUGFIX] Fluid: Removed a leading backslash in ViewHelperBaseTestcase that led to an error with PHP < 5.3
    
    [+TASK] Fluid: Backported some recent Fluid changes (Note: this is not a complete backport, there are still changes in Fluid Package that are not backported yet):
      [+BUGFIX] Fluid (ViewHelpers): form.select ViewHelper did only check whether "multiple" attribute was set and not whether it was empty or not. Resolves #5879
      [+FEATURE] Fluid (ViewHelpers): GroupedForViewHelper can now group by object. Resolves #7389

commit 5c8c4d6012158d52bf1618cb25ef066d9f639f31
Author: Bastian Waidelich <*****@typo3.org>
Date:   Sun Nov 14 13:38:48 2010 +0000

    [+FEATURE] Fluid (Core/Widget): Added Tx_Fluid_Core_Widget_Bootstrap that is used to dispatch Ajax requests (see ext_typoscript_setup.txt).
    [~TASK] Fluid (Compatibility): Removed Tx_Fluid_Compatibility_ObjectManager and replaced instances by Tx_Extbase_Object_ObjectManagerInterface instances
    [~TASK] Fluid (Core/Widget): AbstractWidgetController has to be a singleton so it can be injected in the WidgetViewHelper.. To be discussed!
    [+TASK] Fluid (Core/Widget): AjaxWidgetContextHolder is now correctly stored in the BE/FE Users session if the ajaxWidget of the corresponding Widget is TRUE.
    [+TASK] Fluid (Core/Widget): The WidgetContext now contains a reference to the parent extension & plugin name. That's needed for the widgetAjaxResponse.
    [+BUGFIX] Fluid (Core/Widget): WidgetRequestBuilder now correctly interprets GET parameters and dispatches Ajax requests
    [+BUGFIX] Fluid (ViewHelpers): Modified ViewHelpers cObject, format.crop, format.html, image, uri.image so that they use dependency injection in order to retrieve the current cObject instance from the configurationManager
    [+BUGFIX] Fluid (ViewHelpers): Fixed form ViewHelper to respect configured pluginNamespace in field name prefixes
    [+BUGFIX] Fluid (ViewHelpers): link.widget/uri.widget ViewHelpers now create correct URIs
    [+BUGFIX] Fluid (ViewHelpers):*****@inject annotation by injectController method in AutocompleteViewHelper.

commit c98945130824aebbdef271d7244aec8cd29c794e
Author: Bastian Waidelich <*****@typo3.org>
Date:   Tue Nov 16 23:49:43 2010 +0000

    [+BUGFIX] Fluid (ViewHelpers): replaced two occurrences of Tx_Extbase_Dispatcher::*() by using the injected ConfigurationManager
    [+TASK] Fluid (ViewHelpers): uri.image now works in BE mode too

commit dd8928aed4c119d8db37322acb91ded24ba5cc35
Author: Bastian Waidelich <*****@typo3.org>
Date:   Thu Dec 30 16:21:11 2010 +0000

    [+TASK] Fluid (ViewHelpers): Fix, cleanup and extend inline documentation of ViewHelpers
    
    Resolves #10908

commit fd09d197fa8886b97cb20aa9573f39cd08ce989e
Author: Bastian Waidelich <*****@typo3.org>
Date:   Thu Nov 10 18:27:58 2011 +0100

    [TASK] S*****@author annotations
    
    This backports three recent changes of the TYPO3.Fluid package:
    - R*****@license annotation from files (290f4f5)
    - Simplify license header in PHP files (14bacba)
    - D*****@author tags from source code (9c2e837)
    
    This should not contain any functional change!
    
    Change-Id: I9376dca4af78c4f0f82413011d115b8ad04634dd

commit ec3891d8d4e339d8319428211207e6201be9fd73
Author: Thomas Maroschik <*****@dfau.de>
Date:   Wed Oct 17 21:18:26 2012 +0200

    [TASK][WIP] Move non class code back to source files
    
    Change-Id: I620d2e61860142cdc89cc83474c95542799961c0

commit 554e8f890dcc0dd86a27518b58e2b54be26fd37e
Author: Thomas Maroschik <*****@dfau.de>
Date:   Wed Oct 17 22:20:17 2012 +0200

    [TASK] Namespace classes
    
    Change-Id: Ia7432e1c923826ed58206bca15fb94509adbd508

commit 547ef7f60f39c6bfcb0376e5e76070da85860098
Author: Arvid Jakobsson <*****@gmail.com>
Date:   Mon Sep 17 21:25:51 2012 +0200

    [TASK] Remove superfluous parenthesis in sysexts
    
    Superfluous brackets in fluid after namespaces move
    Change ("a" . "b") . "c" into "a" . "b" . "c" using the lex-pass tool.
    
    Resolves: #41016
    Related: #40095
    Releases: 6.0
    Change-Id: I64741473cb24eda343f0576ebd1a0f1846dfc3f8
    Reviewed-on: http://review.typo3.org/14675
    Reviewed-by: Oliver Hader
    Tested-by: Oliver Hader

commit 9d46e6932d35c79bf87c96fa38b8e537c4192f23
Author: Alexander Schnitzler <*****@typovision.de>
Date:   Tue Nov 20 16:27:02 2012 +0100

    [CLEANUP] Adjust code to CGL and fix small namespace bugs
    
    * whitespaces, tabs and blank line issues
    * bool -> boolean
    * int -> integer
    * fix wrong namespace annotations
    
    Fixes: #43157
    Releases: 6.0
    Change-Id: I8397948e19248db029d8efd1555ee56e4982742d
    Reviewed-on: http://review.typo3.org/16619
    Reviewed-by: Helmut Hummel
    Tested-by: Helmut Hummel

commit 7bdd9f98e8c7d8dd54e7328869382482562ffac4
Author: Wouter Wolters <*****@wouterwolters.nl>
Date:   Sun Mar 10 22:42:07 2013 +0100

    [TASK] Cleanup fluid
    
    - Remove dead code
    - Add missing property definitions
    - Add function descriptions
    
    Change-Id: I0ec563d42d7e763db7f482c9721edb4717703213
    Resolves: #46162
    Releases: 6.1
    Reviewed-on: https://review.typo3.org/18831
    Reviewed-by: Anja Leichsenring
    Tested-by: Anja Leichsenring
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn

commit 0e0621f7c7d7ebb8358fac804759707ed81545a9
Author: Anja Leichsenring <*****@ab-softlab.de>
Date:   Wed Dec 26 09:44:43 2012 +0100

    [BUGFIX] Add needed setting to handle file_references correctly
    
    The Uri.Image ViewHelper needs the setting 'treatIdAsReference' to
    handle file_references correctly.
    
    Change-Id: Ia3df9dffd801e5f88343d60bcc352e39e89179ee
    Fixes: #44222
    Releases: 6.0, 6.1
    Reviewed-on: https://review.typo3.org/17274
    Reviewed-by: Stefan Neufeind
    Tested-by: Stefan Neufeind
    Reviewed-by: Wouter Wolters
    Tested-by: Wouter Wolters

commit fae04a024687fd061c41d67076cfb455d189aefc
Author: Christian Kuhn <*****@schwarzbu.ch>
Date:   Wed May 1 17:57:52 2013 +0200

    [BUGFIX] Mentions of old class names
    
    Change-Id: Iee7a863a9d68d1379e1e616414b9848e0c535a8a
    Resolves: #47791
    Releases: 6.2
    Reviewed-on: https://review.typo3.org/20378
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn

commit 77f29a3c69a7cbb27b34072754aa503bace6c9f1
Author: Christian Kuhn <*****@schwarzbu.ch>
Date:   Tue Oct 1 14:40:56 2013 +0200

    [TASK] Remove closing PHP tags
    
    Change-Id: Iaa92566c53301e49396fc9fb26b0b339c48d567b
    Resolves: #52360
    Releases: 6.2
    Reviewed-on: https://review.typo3.org/24212
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn
    Reviewed-by: Ernesto Baschny
    Tested-by: Ernesto Baschny
    Reviewed-by: Anja Leichsenring
    Tested-by: Anja Leichsenring

commit 3d976ac9f24159e1a7cb6e6894de66e44b1b43fc
Author: Helmut Hummel <*****@typo3.org>
Date:   Sun Oct 20 18:38:47 2013 +0200

    [TASK] Rework image viewHelper to use FAL
    
    Currently in the worst case images are transformed
    from Extbase domain objects to FAL objects to paths
    to FAL objects again just to render an image.
    
    Avoid back and forth conversions an directly use
    FAL API instead of using the detour through
    the content object renderer.
    
    Resolves: #53700
    Releases: 6.2
    Change-Id: I5fe8d7c9d4ad94e99b5bac06e54ff1346e8cc187
    Reviewed-on: https://review.typo3.org/24911
    Reviewed-by: Markus Klein
    Tested-by: Markus Klein
    Reviewed-by: Jigal van Hemert
    Tested-by: Jigal van Hemert