Skip to content

Calling toHtml on Media model doesn't return alt, unless defined via attributes #3535

@kikky7

Description

@kikky7

If I don't specify alt within attributes, then output has no alt tag, looking into responsiveImageWithPlaceholder.blade.php, there is also no alt attribute. Isn't name column here to be used as alt?

$media = $this->getFirstMedia('image');

return $media
            ->img()
            ->attributes([
                'class' => 'w-full h-full object-cover object-center',
                'alt' => $media->name, // without this no alt in the output
            ])
            ->toHtml();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions