:navigation-title: image .. include:: /Includes.rst.txt .. _typo3-fluid-image: ============================ Image ViewHelper `` ============================ .. typo3:viewhelper:: image :source: ../Global.json :display: tags,description,gitHubLink :noindex: .. contents:: Table of contents .. _typo3-fluid-image-src: Argument src - displaying images from extension assets ====================================================== Images used for design purposes and not content purposes are commonly shipped in an extension. These images cannot be edited by backend users. They can be displayed using the `` ViewHelper using the :ref:`src ` argument and `EXT:` syntax: .. code-block:: html In the extension the assets **must** be stored under :path:`Resources/Public/` or a subfolder of this folder. If you installed the extension via Composer **before** it had a folder of that exact name, reinstall it so that the symlinks in folder :path:`public/_assets` are correctly created for you. .. note:: Avoid using image operations such as the arguments :ref:`width ` or :ref:`crop ` with images included from an extensions' assets. Each non-FAL image operation creates a "fake" FAL record, which may lead to problems. .. _typo3-fluid-image-image: Argument image - display images from the folder fileadmin / from FAL ==================================================================== Folders from inside the folder :path:`fileadmin` are usually accessed using the `file abstraction layer (FAL) `_. For example, if you want to display an image that is attached to a content element, the content element typically stores a reference count of attached images in its `media` field. Intermediate tables are then used to attach the actual image to the content elements. This allows backend users to move or rename files, without the files connection being lost in the content element. .. _typo3-fluid-image-fluidtemplate: FLUIDTEMPLATE and data processors and images -------------------------------------------- In a TypoScript `FLUIDTEMPLATE `_ you can use the `files data processor `_ to display an image with the `` ViewHelper. See `Example: Render the images stored in field image `_ in the TypoScript reference. You can then use the :ref:`image ` argument to pass the :php-short:`\TYPO3\CMS\Core\Resource\File` or :php-short:`\TYPO3\CMS\Core\Resource\FileReference` provided by the TypoScript data processor to the ViewHelper. .. code-block:: html The :abbr:`FAL (file abstraction layer)` will scale the image and convert it to a web format if necessary (for example from a pdf to a png). The `` ViewHelper generates a HTML `` tag with the correct paths, etc. .. _typo3-fluid-image-extbase: Images from Extbase models in Fluid ----------------------------------- In Extbase models you can use fields of type :php:`\TYPO3\CMS\Extbase\Persistence\ObjectStorage` with the TCA type `File `_. When you are looping through the object storage, each element will be of type :php:`\TYPO3\CMS\Extbase\Domain\Model\FileReference`. They can be used with the :ref:`image ` argument: .. code-block:: html If the field should only contain a maximum of one image (`maxitems=1 `_), you can display the image simply by selecting the first array element: .. code-block:: html .. _typo3-fluid-image-uidreference: Using the UID of the database entry directly ============================================ If you have the UID of the **sys_file_reference** table (preferred) you have to set :ref:`treatIdAsReference ` to true and pass the UID of the file reference to the :ref:`src ` argument. If only the UID of the **sys_file** table is available, you can pass this value to the :ref:`src ` argument of the ViewHelper and `treatIdAsReference` can be kept as the default value (false). In this case no data from the file reference, such as default cropping or overrides for alt text and description, will be available. .. code-block:: html .. _typo3-fluid-image-typolink: Displaying an image using its typolink string ============================================= If the file is configured as a typolink, for example from a TCA field of type `Link `_, you can use the typolink string, starting with `t3://file`, as :ref:`src `: .. code-block:: html .. _typo3-fluid-image-example: Embedding SVG files with the base64 attribute ============================================= When the :typo3:viewhelper-argument:`base64 ` argument is set to true, the resulting image tag will contain the source of the image in a base64 encoded form. .. code-block:: html This will result in the HTML tag providing the image encoded in base64. .. code-block:: html This can be particularly useful inside `FluidEmail `_ or to prevent unnecessary HTTP calls. .. _typo3-fluid-image-arguments: Arguments of the `` ViewHelper ======================================= .. include:: /_Includes/_ArbitraryArguments.rst.txt .. typo3:viewhelper:: image :source: ../Global.json :display: arguments-only