Problem/Motivation

The Radix theme’s image component currently outputs empty attributes on the <img> tag when these values are not provided. This results in HTML such as:
<img data-component-id="radix:image" class="page" src="/themes/custom/radix-3537368/logo.svg" alt="" title="" width="" height="" loading="auto">

This issue is to clean up the markup, ensuring attributes are only rendered when they hold valid values.

Steps to reproduce

1) Implement the component:
Use the Radix image component in your Twig template without specifying attributes. For example:

{% include 'radix:image' with {
  src: '/themes/contrib/radix/logo.svg',
} %}

2) Review output:
Inspect the rendered HTML in the browser via the developer tools.

3) Observe the issue:
Notice that the <img> tag includes empty alt, title, width and height attributes:
<img data-component-id="radix:image" class="page" src="/themes/custom/radix-3537368/logo.svg" alt="" title="" width="" height="" loading="auto">

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork radix-3538686

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anirudhsingh19 created an issue. See original summary.

anirudhsingh19’s picture

working on it!

anirudhsingh19’s picture

Assigned: anirudhsingh19 » Unassigned
Status: Active » Needs review
StatusFileSize
new56.16 KB
new56.47 KB

I've made the required changes in the image.twig file. I've ensured that attributes like width, height and title are only added when values are provided. The alt attribute can still be rendered empty to support decorative images as per accessibility best practices.

Marking this to Needs Review

doxigo’s picture

Status: Needs review » Fixed

Thanks for the MR, merged.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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