Skip to content
Snippets Groups Projects

Inline logo SVG.

Open Nicholas Mangold requested to merge issue/drupal-3345259:3345259-logo-inline-svg into 11.x
2 unresolved threads

Closes #3345259

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
18 19 {% block content %}
19 20 {% if site_logo %}
20 21 <a href="{{ path('<front>') }}" rel="home">
21 <img src="{{ site_logo }}" alt="{{ 'Home'|t }}" fetchpriority="high" />
22 {% if site_logo|split('.')|last == "svg" %}
  • Not sure this logic should live in the template, given the actual markup is the same, can we not change the behaviour of the site_logo variable depending on whether it's an svg or not? Then it wouldn't require any template changes at all.

  • @catch I don't follow, "...given the actual markup is the same...". One includes the SVG file inline using an <svg> tag, the other renders the image using an <img> tag. The markup is not the same.

  • @nmangold I mean that the markup in the Twig file is the same - the only conditional is on which variable to use. So if we moved that conditional into the creation of the variable itself, then it wouldn't require a template change.

  • @catch The conditional is not only on which variable to use. Each of those variables are rendered differently. The SVG uses {% include ... %} to execute the statement and insert the contents of the file. The other uses {{ ... }} to print the variable. If we only use one variable, {{ ... }} is going to print the file URI in the case for SVGs, not insert the file contents.

    If I can include the content of the SVG when creating the variable, and print that using {{ ... }} the SVG content is printed as a string.

    Is there a way I can include the contents of the SVG when building the variable and pass that to the Twig file such that it will be rendered properly? With everything I have tried, I either get the SVG contents printed as a string, or nothing.

  • Nicholas Mangold changed this line in version 6 of the diff

    changed this line in version 6 of the diff

  • I figured out a way. It is much cleaner and straightforward now.

  • Please register or sign in to reply
  • added 1 commit

    • a3b9036b - Move extension logic to the block plugin, and allow templates to render the logo the same way.

    Compare with previous version

  • added 1 commit

    • 1fbe9911 - Remove documentation for unused variable.

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 313 313 switch ($variables['base_plugin_id']) {
    314 314 case 'system_branding_block':
    315 315 $variables['site_logo'] = '';
    316 if ($variables['content']['site_logo']['#access'] && $variables['content']['site_logo']['#uri']) {
    317 $variables['site_logo'] = $variables['content']['site_logo']['#uri'];
    316 if ($variables['content']['site_logo']['#access']) {
    317 $variables['site_logo'] = $variables['content']['site_logo'];
    • Comment on lines +316 to +317

      @catch I believe this would not be needed if {{ content.site_logo }} is used in the template, but would that be considered a breaking change? Since, $site_logo is defined and used currently.

    • Please register or sign in to reply
  • added 1 commit

    • 88c15792 - Check if index exists and explicitly check if it is TRUE. Fixes failing...

    Compare with previous version

  • Nicholas Mangold added 63 commits

    added 63 commits

    • 88c15792...a0a7640c - 53 commits from branch project:11.x
    • 9c8937d2 - Inline logo SVG.
    • c4dd8ddb - Included rendered version the logo so attributes are added to images that are...
    • 390f1b7b - Fixed PHPCS violation. Parameter $image_factory is not described in comment
    • 91da2eae - Fixed PHPCS violation. Parameter $image_factory is not described in comment.
    • 6af0fb13 - Fixed PHPCS violation.
    • 05a59136 - Move extension logic to the block plugin, and allow templates to render the logo the same way.
    • 317419a3 - Remove documentation for unused variable.
    • 73346ffe - Fix PHPCS violation.
    • f919acf5 - Remove extra space.
    • 775cd53d - Check if index exists and explicitly check if it is TRUE. Fixes failing...

    Compare with previous version

  • Nicholas Mangold added 11 commits

    added 11 commits

    • 3a1cecfd - 1 earlier commit
    • 54ef5dda - Included rendered version the logo so attributes are added to images that are...
    • ebc0824b - Fixed PHPCS violation. Parameter $image_factory is not described in comment
    • e6ecf4a4 - Fixed PHPCS violation. Parameter $image_factory is not described in comment.
    • d8a5b282 - Fixed PHPCS violation.
    • a3b9036b - Move extension logic to the block plugin, and allow templates to render the logo the same way.
    • 1fbe9911 - Remove documentation for unused variable.
    • 00c98e93 - Fix PHPCS violation.
    • 0842bb43 - Remove extra space.
    • 88c15792 - Check if index exists and explicitly check if it is TRUE. Fixes failing...
    • a48829a0 - Merge remote-tracking branch 'drupal-3345259/3345259-logo-inline-svg' into 3345259-logo-inline-svg

    Compare with previous version

  • Nicholas Mangold added 158 commits

    added 158 commits

    Compare with previous version

  • Please register or sign in to reply
    Loading