Allow custom field formatter plugins to utilise this module

Created on 7 November 2022, about 2 years ago
Updated 6 September 2024, 4 months ago

Problem/Motivation

Currently this module limits to only applying to the image or responsive_image field formatters. If we have implemented a custom field formatter for images then this module won't apply to them, even if we want it to.

Proposed resolution

In custom field formatters we can add the option "lazy_loader = TRUE" to the @FieldFormatter annotation. Then if this is set we allow the lazy loader third party settings form to be added to the field formatter, thus allowing the module to be applied to these field formatters.

I have attached a patch that does this here.

Feature request
Status

Fixed

Version

2.1

Component

Code

Created by

🇬🇧United Kingdom mjmorley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom aaron.ferris

    Ive tested/reviewed this - looks good to me.

    Setup

    1. Drupal 10.2.6
    2. Latest version of this module
    3. The proposed patch
    4. A custom image formatter
    5. Annotation as described in the OP
    /**
     * Plugin implementation of the 'new image' formatter.
     *
     * @FieldFormatter(
     *   id = "new_image_formatter",
     *   label = @Translation("New Image Formatter"),
     *   lazy_loader = TRUE,
     *   field_types = {
     *     "image"
     *   }
     * )
     */

    Works as I would expect, the option to assign lazy_loader is in the field display config. The markup includes the class the module provides,

    <img loading="lazy" src="" width="480" height="368" alt="Alt text" data-src="/sites/default/files/styles/large/public/2024-08/Screenshot%202024-07-31%20at%2015.27.29.png?itok=vSuZn-oA" class="lozad" data-vd-id="element-qak7f">

    RBTC

  • Status changed to RTBC 5 months ago
  • First commit to issue fork.
  • Status changed to Fixed 5 months ago
  • 🇬🇧United Kingdom psebborn

    Thanks all! Merged; will be added to the next release

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇬🇧United Kingdom psebborn
Production build 0.71.5 2024