Code Monkey home page Code Monkey logo

fluid-styled-responsive-images's Introduction

TYPO3 CMS Extension "fluid_styled_responsive_images"

Build Status

This project aims to provide an image-rendering process that will render responsive images with fluid, where the assumption is made, that TYPO3 CMS doesn't provide a mechanism outof the box for fluid templates while one is able to do it with TypoScript.

Installation

a) install the stable version from the TYPO3 CMS Extension Repository (TER) through the extension manager b) install via composer using the current stable release and track new stable releases: composer require "typo3-ter/fluid-styled-responsive-images ^1.2" and enable the extension through the extension manager / your preferred mechanism c) use the current development version by either requiring "typo3-ter/fluid-styled-responsive-images": "dev-master" in your composer.json file, run composer update d) clone the current development version to your typo3conf/ext directory (ex. cd typo3conf/ext && rm -Rf fluid_styled_responsive_images && git clone https://github.com/alexanderschnitzler/fluid-styled-responsive-images.git fluid_styled_responsive_images)

Configuration

The extension is configured through TypoScript, like most parts of your site are. Include the static TypoScript of the extension and then begin with the Configuration through your own TypoScript setup.

The ImageRenderer currently supports the [srcset](srcset specification) and rendering as data-attributes, which is to make custom rendering with javascript easier.

Minimal, empty configuration:

tt_content.textmedia.settings.responsive_image_rendering {
    layoutKey = srcset

    sourceCollection {
        # Please write your own sourceCollection configuration
    }
}

Mode srcset

A sourceCollection entry is a TypoScript hash. It can contain the following indices:

key description example
width The target size of the generated image. Supports modifications like m & c 1200c (crops the image to 1200px)
srcset a string describing the condition under which the image is displayed 1200w (1200px viewports)
dataKey a name for the generated data-attribute desktop
sizes [optional] a media query with custom styles to be applied (min-width: 1200px) 1170px

For more precise descriptions, please check out the html img element specification on srcset.

Configuration Example

tt_content.textmedia {
    settings {
        responsive_image_rendering {
            layoutKey = srcset

            sourceCollection {
                10 {
                    dataKey = desktop
                    width = 1260m
                    srcset = 1260w
                }

                20 {
                    dataKey = table
                    width = 960m
                    srcset = 960w
                }

                30 {
                    dataKey = tablet-small
                    width = 720m
                    srcset = 720w
                }

                40 {
                    dataKey = medium
                    width = 640m
                    srcset = 640w
                }

                50 {
                    dataKey = medium-phone
                    width = 360m
                    srcset = 360w
                }

                60 {
                    dataKey = small
                    width = 320m
                    srcset = 320w
                }
            }
        }
    }
}

Usage

After installation and configuration, the output of the <f:media> viewhelper uses the logic this extension supplies for images and renders the image.

Inner workings

  1. a custom image renderer is registered
  2. when the RendererRegistry is asked for a renderer suitable for the current mimetype, the renderer proposes itself if one of the known image mimetypes is matched
  3. the renderer reads the current TypoScript and merges it with global extension configuration like the enableSmallDefaultImage setting
  4. the renderer then calculates the needed sizes and returns a ready-made img-tag

Extending fluid_styled_responsive_images

Since fluid_styled_content is used, much of the output in TYPO3 CMS can be adjusted.

Example of registering custom templates and adjusting images in collaboration with the GalleryProcessor in fluid_styled_content to provide precise rendering with Bootstrap 3 based templates: websightgmbh/ws-texmedia-bootstrap.

License

GPL-2.0+

fluid-styled-responsive-images's People

Contributors

alexanderschnitzler avatar cedricziel avatar fazzyx avatar franzkugelmann avatar whiteroom avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.