.. include:: /Includes.rst.txt .. Copyright (c) 2025-2026 Netresearch DTT GmbH SPDX-License-Identifier: AGPL-3.0-or-later .. _integration-configuration-frontend-rendering: ================== Frontend Rendering ================== TypoScript configuration for frontend image rendering, CSS classes, lazy loading, and lightbox integration. .. important:: **TypoScript Required for Frontend Rendering** After installing the extension, you must include the TypoScript for frontend image rendering. **Option 1: Static Template** #. Go to :guilabel:`WEB > Template` module. #. Select your root page. #. Edit the template. #. In :guilabel:`Includes` tab, add: :guilabel:`CKEditor Image Support (rte_ckeditor_image)`. **Option 2: Direct Import** Add to your site package TypoScript: .. code-block:: typoscript :caption: Import in your site package @import 'EXT:rte_ckeditor_image/Configuration/TypoScript/ImageRendering/setup.typoscript' This loads: - Image rendering hooks (:typoscript:`lib.parseFunc_RTE.tags.img`). - Link rendering hooks (:typoscript:`lib.parseFunc_RTE.tags.a`) — resolves ``t3://`` URLs and validates protocols. - Figure rendering hooks (:typoscript:`lib.parseFunc_RTE.externalBlocks.figure`). - HTMLparser configuration for data attribute cleanup. Using direct import gives you full control over the TypoScript load order, allowing you to override settings (like lightbox configuration) after the import. .. note:: The static template and the direct import cover frontend rendering only. They do not include the image alignment CSS (``EXT:rte_ckeditor_image/Resources/Public/Css/image-alignment.css``), the popup link class override for Bootstrap Package (``linkClass = lightbox``) or the page TSconfig that activates the ``rteWithImages`` preset. The Site Set ``netresearch/rte-ckeditor-image`` includes all of them. .. contents:: Table of Contents :depth: 3 :local: TypoScript Configuration ======================== Frontend Rendering Setup ------------------------- The extension provides default configuration. You can customize it: .. versionchanged:: 13.1.5 The legacy :php:`ImageRenderingController` and :php:`ImageLinkRenderingController` were replaced with unified :php:`ImageRenderingAdapter` using the new service architecture. See :ref:`api-services` for details. .. code-block:: typoscript :caption: Frontend rendering configuration lib.parseFunc_RTE { tags.img = TEXT tags.img { current = 1 preUserFunc = Netresearch\RteCKEditorImage\Controller\ImageRenderingAdapter->renderImageAttributes } tags.a = TEXT tags.a { current = 1 typolink { parameter.data = parameters:href title.data = parameters:title ATagParams.data = parameters:allParams target.ifEmpty.data = parameters:target } } tags.a.preUserFunc = Netresearch\RteCKEditorImage\Controller\ImageRenderingAdapter->prepareInlineLinkContent nonTypoTagStdWrap.HTMLparser.tags.img.fixAttrib { # Remove internal data attributes from frontend allparams.unset = 1 data-htmlarea-file-uid.unset = 1 data-htmlarea-file-table.unset = 1 # Keep zoom attributes for popup/lightbox rendering (ImageRenderingAdapter.php) # data-htmlarea-zoom.unset = 1 # data-htmlarea-clickenlarge.unset = 1 data-title-override.unset = 1 data-alt-override.unset = 1 } } lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.encapsTagList := addToList(img) .. important:: ``ATagParams.data = parameters:allParams`` passes the stored link attributes through. Keep ``lib.parseFunc_RTE.htmlSanitize`` enabled (the TYPO3 default) so the sanitizer removes event handlers such as ``onclick`` from editor content. Default CSS Class ----------------- Add default class to all RTE images: .. code-block:: typoscript :caption: Default CSS class configuration lib.parseFunc_RTE { nonTypoTagStdWrap.HTMLparser.tags.img.fixAttrib.class { default = img-fluid responsive-image } } Lazyload Configuration ---------------------- Enable native browser lazy loading: .. code-block:: typoscript :caption: Template constants for lazy loading styles.content.image.lazyLoading = lazy # Options: lazy, eager, auto Lightbox/Popup Integration -------------------------- .. versionadded:: 13.1.5 Default popup configuration is now provided by the extension. .. note:: **Site Set Configuration (TYPO3 v13+)** The extension provides click-to-enlarge functionality once TypoScript is included. The extension's site set also ensures the loading order with :typoscript:`fluid_styled_content`, includes the image alignment CSS and activates the ``rteWithImages`` preset in the backend: **Option 1: Via Backend (Recommended for TYPO3 v13+)** #. Go to :guilabel:`Site Management > Sites` module. #. Edit your site. #. In :guilabel:`Sets` tab, add: :guilabel:`CKEditor Image Support`. #. Save. **Option 2: Via config.yaml** Edit :file:`config/sites//config.yaml`: .. code-block:: yaml :caption: Site configuration with extension dependency base: 'https://example.com/' rootPageId: 1 dependencies: - netresearch/rte-ckeditor-image **Option 3: Static Template** Without site sets, you can include the static template (frontend rendering only): #. Go to :guilabel:`WEB > Template` module. #. Select your root page. #. Edit the template. #. In :guilabel:`Includes` tab, add: :guilabel:`CKEditor Image Support (rte_ckeditor_image)`. **Why use site sets?** TYPO3 v13 site sets provide proper dependency ordering with :typoscript:`fluid_styled_content`, ensuring TypoScript loads in the correct sequence. The extension provides :typoscript:`lib.contentElement.settings.media.popup` configuration with sensible defaults for click-to-enlarge functionality. When editors enable :guilabel:`Enlarge on Click` in the image dialog, the image is wrapped in a link to the original file with ``target="_blank"``, ``data-popup="true"`` and ``rel="lightbox-group-rte"``. The link class comes from ``linkClass`` (default ``popup-link``; the Site Set sets ``lightbox``) or from the ``class`` in ``linkParams.ATagParams``. **Default Configuration** (included in the static template): .. code-block:: typoscript :caption: Default popup configuration lib.contentElement.settings.media.popup { # Only linkClass and linkParams.ATagParams affect RTE images. # The other keys are fluid_styled_content's popup settings for # content-element images; RTE image links open the file in a new tab. bodyTag = wrap = | width = 800m height = 600m JSwindow = 1 JSwindow.newWindow = 1 directImageLink = 0 } **Using with Lightbox Libraries** (PhotoSwipe, GLightbox, etc.): Override the default configuration to set the CSS class of the popup link: .. code-block:: typoscript :caption: Lightbox library configuration lib.contentElement.settings.media.popup { # CSS class of the popup link linkClass = lightbox } Only the link class is configurable. Other attributes in ``linkParams.ATagParams`` are ignored, and ``rel`` is always ``lightbox-group-rte``. Manual TypoScript Inclusion =========================== .. versionchanged:: 13.4.0 TypoScript is no longer automatically loaded. Manual inclusion is required. See :ref:`integration-configuration-frontend-rendering` for inclusion options. The extension requires manual TypoScript inclusion, giving you full control over load order and the ability to override settings in your site package. **Include via Static Template:** #. Go to :guilabel:`WEB > Template` module #. Select your root page #. In :guilabel:`Includes` tab, add: :guilabel:`CKEditor Image Support` **Or import directly in your site package:** .. code-block:: typoscript :caption: Direct import in site package TypoScript @import 'EXT:rte_ckeditor_image/Configuration/TypoScript/ImageRendering/setup.typoscript' # Now you can override settings: lib.contentElement.settings.media.popup { linkClass = lightbox } .. _typoscript-reference: TypoScript Reference ==================== Complete TypoScript Configuration Options ------------------------------------------ Image Rendering ~~~~~~~~~~~~~~~ .. code-block:: typoscript :caption: Image tag processing lib.parseFunc_RTE { tags.img = TEXT tags.img { current = 1 preUserFunc = Netresearch\RteCKEditorImage\Controller\ImageRenderingAdapter->renderImageAttributes } } Link Rendering ~~~~~~~~~~~~~~ The ```` around a linked image is built by the standard :typoscript:`typolink`. :php:`prepareInlineLinkContent()` only strips nested link wrappers from historical double-wrapped content before that. .. code-block:: typoscript :caption: Link tag processing for linked images lib.parseFunc_RTE { tags.a = TEXT tags.a { current = 1 typolink { parameter.data = parameters:href title.data = parameters:title ATagParams.data = parameters:allParams target.ifEmpty.data = parameters:target } } tags.a.preUserFunc = Netresearch\RteCKEditorImage\Controller\ImageRenderingAdapter->prepareInlineLinkContent } .. deprecated:: 13.7.0 :php:`renderInlineLink()` as :typoscript:`tags.a.preUserFunc` is deprecated. Use :php:`prepareInlineLinkContent()` with the typolink configuration above. HTML Parser Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: typoscript :caption: HTMLparser attribute cleanup lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser.tags.img { fixAttrib { # Remove internal data attributes data-htmlarea-file-uid.unset = 1 data-htmlarea-file-table.unset = 1 # Keep zoom attributes for popup/lightbox rendering (ImageRenderingAdapter.php) # data-htmlarea-zoom.unset = 1 # data-htmlarea-clickenlarge.unset = 1 data-title-override.unset = 1 data-alt-override.unset = 1 } } Default CSS Classes ~~~~~~~~~~~~~~~~~~~ .. code-block:: typoscript :caption: Default and allowed CSS classes lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser.tags.img.fixAttrib.class { default = img-fluid list = img-fluid,img-thumbnail,rounded } Lazy Loading ~~~~~~~~~~~~ .. code-block:: typoscript :caption: Native browser lazy loading # Template Constants styles.content.image.lazyLoading = lazy # Options: lazy, eager, auto Lightbox Configuration ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: typoscript :caption: Popup link class lib.contentElement.settings.media.popup { # Simple: class of the popup link (default: popup-link) linkClass = lightbox # Alternative: only the class attribute is read from ATagParams. # It is used only while linkClass is unset or empty; the Site Set # sets linkClass = lightbox, so remove that first. # linkParams.ATagParams = class="lightbox" } Image Processing ~~~~~~~~~~~~~~~~ .. code-block:: typoscript :caption: Image dimension processing lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser.tags.img { width = height = # Allows TYPO3 to process dimensions } Encapsulation Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: typoscript :caption: Image encapsulation in paragraphs lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines { encapsTagList := addToList(img) remapTag.img = p } Backend Preview Styling ~~~~~~~~~~~~~~~~~~~~~~~ .. versionadded:: 13.5 The extension automatically registers an image-aware preview renderer for all CTypes with RTE-enabled bodytext (e.g. ``text``, ``textmedia``, ``textpic``). This ensures images are visible in the Page module preview. By default, preview images render at their original size. To limit image dimensions in the backend Page module, add a custom backend stylesheet: .. code-block:: css :caption: EXT:your_sitepackage/Resources/Public/Css/backend.css /* Limit RTE image preview size in Page module */ .t3-page-ce-body img { max-width: 200px; max-height: 150px; } Register the stylesheet in your site package: .. code-block:: php :caption: EXT:your_sitepackage/ext_localconf.php $GLOBALS['TYPO3_CONF_VARS']['BE']['stylesheets']['your_sitepackage'] = 'EXT:your_sitepackage/Resources/Public/Css/backend.css'; .. seealso:: `TYPO3 Changelog: Load additional stylesheets in backend `__ Related Documentation ===================== Configuration Topics -------------------- - :ref:`integration-configuration-rte-setup` - RTE configuration and basic setup - :ref:`integration-configuration-tsconfig` - Page TSConfig settings and upload configuration - :ref:`integration-configuration-advanced` - Advanced configuration, styles, and best practices General Documentation --------------------- - :ref:`integration-configuration` - Main configuration guide overview - :ref:`quick-start` - Quick start guide - :ref:`troubleshooting-index` - Troubleshooting guide