File module's FilemimeFormatter icon display renders empty image

Created on 7 September 2017, almost 7 years ago
Updated 25 October 2023, 8 months ago

Problem/Motivation

The file module's FilemimeFormatter has a option to render the File Mime type as a image.
If selected, it renders as an empty image - no src value etc.

Proposed resolution

The file link formatter correctly generates an icon class, converting various mime types to simple mime types. The classy base them then through css renders an icon. This works well.

My resolution is to add an extra preprocess function in file.module and templates in stable & classy themes.

Attaching a patch for 8.3.x (as that's the version in current usage in the project where bug is discover - so using composer link). Not sure whether this will be able to go into 8.4.x as it is a bug fix or if it should go in 8.5.x as it does change some existing stuff.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
File module 

Last updated 1 day ago

Created by

🇨🇦Canada NickDickinsonWilde Victoria, BC (T'So-uke lands)

Live updates comments and jobs are added and updated live.
  • Needs frontend framework manager review

    Used to alert the fron-tend framework manager core committer(s) that a front-end focused issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

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.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • 🇦🇹Austria tgoeg

    The patch in #2907414-31: File module's FilemimeFormatter icon display renders empty image produces 4 additional files

    core/b/core/modules/file/templates/file-mime-icon.html.twig
    core/b/core/themes/classy/templates/field/file-mime-icon.html.twig
    core/b/core/themes/stable/templates/field/file-mime-icon.html.twig
    core/b/core/themes/stable9/templates/field/file-mime-icon.html.twig

    that do not differ from the ones at their correct location.

    Attached patch should fix it.

    This patch should be added to the new separate modules classy, stable and stable9.
    I'll open issues there, too.

  • 🇦🇹Austria tgoeg

    Sorry - the patch itself is correct. It's just composer-patches that messes things up in case of newly created files.
    Because it tries all values of patch's -p0 till -p4, it creates new files everywhere. Currently investigating how to prevent that.

  • 🇨🇭Switzerland Berdir Switzerland
    "patchLevel": {
                "drupal/core": "-p2"
            },
    

    that's how you prevent that.

  • 🇦🇹Austria tgoeg

    Yeah, thanks, found out in the meantime.

    This is https://github.com/cweagans/composer-patches/issues/514

    It has the potential to considerably mess up an installation or even create files in locations where they get read/parsed/interpreted.
    Using patches is safer than using git repos for fixing up stuff, but this is a pretty hefty disadvantage. I don't remember seeing a warning for this in any doc regarding patching (but I may be wrong).

  • last update 8 months ago
    Patch Failed to Apply
  • 🇮🇳India _utsavsharma

    Patch for 11.x.
    Could not find this file core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php

  • last update 8 months ago
    30,436 pass, 1 fail
Production build 0.69.0 2024