Theme logo image is rendered without dimensions

Created on 1 March 2023, almost 2 years ago
Updated 14 May 2024, 8 months ago

Problem/Motivation

The logo in olivero is hard-coded. All logos in core are either hard-coded or we _only_ render the image path. Never dimensions. We should. And we might want a holistic solution that passes from theme config the logo and the logo dimensions. For good measure, we could even add loading="eager". That's the default, but adding it is more explicit and instructive.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

The variable to render the theme logo is now logo. The variable site_logo for the system branding block has been deprecated.Module and theme maintainers should update any usages of site_logo to the new variablelogo.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Theme 

Last updated about 12 hours ago

Created by

heddn Nicaragua

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • Issue created by @heddn
  • 🇬🇧United Kingdom catch

    I wonder if this was an unexpected regression from #908282: Remove unnecessary I/O from theme_image() (although that issue was good in general).

    The main issue with this is that we don't have anywhere obvious to store the dimensions, the theme settings just point to a file on disk, there's no file reference or similar.

    We could do what #908282: Remove unnecessary I/O from theme_image() used to do in preprocess and cache it somewhere maybe? It's a bit hacky, but it's minimal and would help page rendering quite a lot.

    Or we could add dimensions to the theme configuration form/config object and prepopulate them from the file info if not explicitly set? This would have the advantage of not needing an extra cache get but you could end up with weird issues if you change your theme logo file without updating the form.

  • 🇬🇧United Kingdom longwave UK

    Could we render the logo alone in its own template, preprocessing the height/width, and leverage the render cache?

  • 🇬🇧United Kingdom catch

    I couldn't remember where the logo is rendered, but it's in SystemBrandingBlock - we could do it directly in there I think, just add the attributes when building the render array. It might even be OK to rely on render caching for of the block, although would need to check that.

  • 🇬🇧United Kingdom catch
  • Status changed to Needs work 10 months ago
  • 🇬🇧United Kingdom catch

    Made a start on this but it's quite painful.

    The pain is mostly because of system_preprocess_block and

    core/modules/system/templates/block--system-branding-block.html.twig
    

    In SystemBrandingBlock we do things 'properly' and use '#theme' => 'image', but then that preprocess and the template just extracts the URI from the image render array and renders the image with hard-coded HTML. Why?

    This means any added attributes get stripped.

    Promoting to a bug because there's no way at all to do this generically at the moment.

    I got around this in stark by adding an extra variable for the rendered image, then using that in the template, it is really ugly but I can't think of any other way except adding an entirely new block and deprecating the old one.

  • Pipeline finished with Failed
    10 months ago
    #132375
  • Pipeline finished with Failed
    10 months ago
    Total: 502s
    #132495
  • Status changed to Needs review 10 months ago
  • 🇬🇧United Kingdom catch

    Deprecated the 'site_logo' variable, adding a change record and a release note, this ought to be reviewable now.

  • Pipeline finished with Failed
    10 months ago
    Total: 527s
    #132510
  • Status changed to Needs work 10 months ago
  • 🇬🇧United Kingdom catch

    That svg logic isn't happy, removed that and also switched to using the image factory for non-svg images.

  • 🇳🇿New Zealand quietone

    Trying to remove the 'See more' from the snippet

  • 🇬🇧United Kingdom longwave UK

    This won't make it into 10.3.

Production build 0.71.5 2024