This module will help to add Lottiefiles animation on Drupal's content. This modules is a field plugin to accept the lottiefiles's json url and the user can add options as per the lottiefiles web player https://lottiefiles.com/web-player, like background colour, loop, control etc.

Similar module not available but there is a similar kind of module available https://www.drupal.org/project/media_entity_lottie but this module working Lottie file format concept not like my module.

Project link

https://www.drupal.org/project/lottiefiles_field

Git instructions

git clone --branch '1.0.x' https://git.drupalcode.org/project/lottiefiles_field.git

Comments

harivenuv created an issue. See original summary.

harivenuv’s picture

Issue summary: View changes
harivenuv’s picture

Issue summary: View changes
harivenuv’s picture

Category: Support request » Task
harivenuv’s picture

Title: [D8][D9]Lottiefiles Field » [D9]Lottiefiles Field
Status: Needs work » Needs review
avpaderno’s picture

Issue summary: View changes

Thank you for applying! Reviewers will review the project files, describing what needs to be changed.

Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smother review.

To reviewers: Please read How to review security advisory coverage applications, What to cover in an application review, and Drupal.org security advisory coverage application workflow.

avpaderno’s picture

Status: Needs review » Needs work

master isn't a branch name used on drupal.org repositories. 1.0.x-dev is a wrong name for release branches.
A new branch needs to be created, made the default one; once this is done, the other branches can be removed.

harivenuv’s picture

Issue summary: View changes
harivenuv’s picture

Status: Needs work » Needs review

Hi @apaderno,

Thanks you for the direction, I have changed the development branch name and removed master also made the default branch to dev.

dev branch 1.0.x (default)

Release tag - 1.0.1

Le Vo Trung Hieu’s picture

Status: Needs review » Needs work

Hi @harivenuv,
I've review branch 2.0.x again and It's display some issue

1. I use drupal-check

 ------ -----------------------------------------------------------------
  Line   src\Plugin\Field\FieldFormatter\LottiefilesFieldFormatter.php
 ------ -----------------------------------------------------------------
  63     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$uri.
  64     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$autoplay.
  65     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$background.
  66     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$controls.
  67     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$hover.
  68     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$loop.
  69     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$mode.
  70     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$speed.
  71     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$selector.
  72     Access to an undefined property
         Drupal\Core\TypedData\TypedDataInterface::$width.
  73     Call to an undefined method
         Drupal\Core\TypedData\TypedDataInterface::getFieldDefinition().
 ------ -----------------------------------------------------------------

 ------ ------------------------------------------------------------------------
  Line   src\Plugin\Field\FieldWidget\LottiefilesFieldWidget.php
 ------ ------------------------------------------------------------------------
  68     Access to an undefined property
         Drupal\link\LinkItemInterface::$autoplay.
  74     Access to an undefined property
         Drupal\link\LinkItemInterface::$background.
  80     Access to an undefined property
         Drupal\link\LinkItemInterface::$controls.
  86     Access to an undefined property Drupal\link\LinkItemInterface::$hover.
  92     Access to an undefined property Drupal\link\LinkItemInterface::$loop.
  102    Access to an undefined property Drupal\link\LinkItemInterface::$mode.
  115    Access to an undefined property Drupal\link\LinkItemInterface::$speed.
 ------ ------------------------------------------------------------------------

 [ERROR] Found 18 errors

2. I use Drupal Coding Standards

FILE: ...cs\drupal-test\web\modules\custom\lottiefiles_field\lottiefiles_field.module
----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------


FILE: ...tiefiles_field\src\Plugin\Field\FieldFormatter\LottiefilesFieldFormatter.php
----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------


FILE: ...custom\lottiefiles_field\src\Plugin\Field\FieldType\LottiefilesFieldItem.php
----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------


FILE: ...om\lottiefiles_field\src\Plugin\Field\FieldWidget\LottiefilesFieldWidget.php
----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------
harivenuv’s picture

Status: Needs work » Needs review
andrei.vesterli’s picture

Hello @harivenuv

You did a great job and it looks like you considered the case when the field cardinality is unlimited which is good. I've tested it and I like how it works. Also, tried to set a wrong URL and I just got a js console log error, not fatal, which is really good.

Here are some things that require improvements:

  • Drupal standard
    phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/lottiefiles_field/
    
    FILE: /var/www/html/web/modules/contrib/lottiefiles_field/README.txt
    ------------------------------------------------------------------------
    FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
    ------------------------------------------------------------------------
      4 | WARNING | [ ] Line exceeds 80 characters; contains 144 characters
      5 | WARNING | [ ] Line exceeds 80 characters; contains 121 characters
      7 | WARNING | [ ] Line exceeds 80 characters; contains 152 characters
     31 | ERROR   | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/lottiefiles_field/src/Plugin/Field/FieldType/LottiefilesFieldItem.php
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     20 | WARNING | Line exceeds 80 characters; contains 117 characters
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/lottiefiles_field/src/Plugin/Field/FieldFormatter/LottiefilesFieldFormatter.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     48 | WARNING | [x] There must be no blank line following an inline comment
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
    Time: 183ms; Memory: 6MB
    

    and DrupalPractice

    phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/lottiefiles_field/
    
    FILE: /var/www/html/web/modules/contrib/lottiefiles_field/src/Plugin/Field/FieldType/LottiefilesFieldItem.php
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     51 | WARNING | Unused variable $settings.
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/lottiefiles_field/src/Plugin/Field/FieldFormatter/LottiefilesFieldFormatter.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     48 | WARNING | There must be no blank line following an inline comment
    -----------------------------------------------------------------------------------------------------------------------
    
    Time: 122ms; Memory: 4MB
    
  • Why don't you use this:
    /**
     * Implements hook_theme().
     */
    function lottiefiles_field_theme() {
      return [
        'lottiefiles_player_formatter' => [
          'variables' => [
            'uri' => NULL,
            'autoplay' => NULL,
            'background' => NULL,
            'controls' => NULL,
            'hover' => NULL,
            'loop' => NULL,
            'mode' => NULL,
            'speed' => NULL,
            'selector' => NULL,
            'width' => NULL,
            'cssselector' => NULL,
          ],
        ],
      ];
    }
    

    instead of declaration of $theme variable?

  • The file templates/lottiefiles-player-formatter.html.twig does not contain all the used variables. You indicate these:
     * Available variables:
     * - image: A collection of image data.
     * - url: An URL the image can be linked to.
     * - attributes: Link attributes.
    

    but you use much more:

    'variables' => [
      'uri' => NULL,
      'autoplay' => NULL,
      'background' => NULL,
      'controls' => NULL,
      'hover' => NULL,
      'loop' => NULL,
      'mode' => NULL,
      'speed' => NULL,
      'selector' => NULL,
      'width' => NULL,
      'cssselector' => NULL,
    ]
    
  • Please, provide a proper composer.json. See this documentation for more information.

Regards,
Andrei

andrei.vesterli’s picture

Status: Needs review » Needs work
harivenuv’s picture

Hello @andrei.vesterli,

Thanks you for your time to review the module.

  1. Fixed the Drupal coding standard issues

    root@13182f5cf728:/var/www/html# ./vendor/bin/phpcs   --standard="Drupal,DrupalPractice" -n   --extensions="php,module,inc,install,test,profile,theme"   web/modules/contrib/lottiefiles_field
    root@13182f5cf728:/var/www/html#
      
  2. $theme variable removed

    /**
     * Implements hook_theme().
     */
    function lottiefiles_field_theme() {
      return [
        'lottiefiles_player_formatter' => [
          'variables' => [
            'uri' => NULL,
            'autoplay' => NULL,
            'background' => NULL,
            'controls' => NULL,
            'hover' => NULL,
            'loop' => NULL,
            'mode' => NULL,
            'speed' => NULL,
            'selector' => NULL,
            'width' => NULL,
            'cssselector' => NULL,
          ],
        ],
      ];
    }
    
  3. Proper comments added

    {#
    /**
     * @file
     * Default theme implementation to display a formatted lottiefiles field.
     *
     * Available variables:
     * - uri: Lottiefiles json url.
     * - autoplay: Flag for autoplay option, autoplay animation on load.
     * - background: Background color of the animation.
     * - controls: Flag for controls option, show controls.
     * - hover: Flag for hover option, play on mouse hover.
     * - loop: Flag for loop option, loop the animation.
     * - mode: play mode.
     * - speed: Animation speed.
     * - selector: Unique ID selector.
     * - width: Width of the animation player in pixel.
     * - cssselector: Unique css selector.
     *
     * @see template_preprocess_lottiefiles_player_formatter()
     *
     * @ingroup themeable
     */
    #}
  4. compose.json file added

    {
        "name": "drupal/lottiefiles_field",
        "description": "Drupal field for lottie animation.",
        "type": "drupal-module",
        "homepage": "http://drupal.org/project/lottiefiles_field",
        "license": "GPL-2.0-or-later",
        "authors": [
            {
                "name": "Hari Venu",
                "email": "harivenu.v1992@gmail.com",
                "homepage": "https://www.drupal.org/u/harivenuv",
                "role": "Maintainer"
            }
        ],
        "minimum-stability": "stable",
        "require": {
            "drupal/core": "^8.8.0 || ^9.0"
        }
    }
    

Please review and approve

Thanks,
Hari

harivenuv’s picture

Status: Needs work » Needs review
andrei.vesterli’s picture

Hi @harivenuv

Nice! Thx for the quick feedback.

Rajeev cp’s picture

Thanks @harivenuv for this awesome module.
I have tested It in my multilingual website and everything worked as expected.

harivenuv’s picture

Priority: Normal » Major
harivenuv’s picture

Priority: Major » Critical

Please review

avpaderno’s picture

Assigned: Unassigned » avpaderno
Priority: Critical » Normal
Status: Needs review » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thank you to all the reviewers.

harivenuv’s picture

Thank you @apaderno

Status: Fixed » Closed (fixed)

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

cmlara’s picture

Issue tags: +Vulnerable when approved

Apologies for the noise.

Adding a tracking flag for auditing when modules have been reviewed by the queue only for it to be announced after approval that reviewed code contained a security vulnerability.

SA-CONTRIB-2022-046