Image Block Default ALT

Permalink
Hey Guys,

I remember earlier when we used to use the Image block and did not add the ALT manually it used to add the name of the image as the ALT by default. It seems on the newer versions this is not happening as it used to previously.

Now on version 8.4.3 when I am trying to add an Image block it is not adding any default alt tag. I would like to have this ALT tag by default.

Is this a new change? Is there any configuration value that can be set for this?

Thanks for your help in advance.

jerryscott
 
adz replied on at Permalink Reply
adz
Hey Jerry, I've answered in Slack but to ensure we have an answer on the forum too, I'll reply here.

So it looks as though there is no fallback for alt text if none is entered in the image block. I don't know if this is by design or not, however, if you want it to fallback to the name or the title of the file add an override controller into your system at: /application/blocks/image/controller.php

<?php
namespace Application\Block\Image;
use Concrete\Block\Image\Controller as SearchBlockController;
class Controller extends SearchBlockController
{
    public function getAltText()
    {
        if (strlen($this->altText) > 0) {
            return $this->altText;
        } else {
            $f = $this->getFileObject();
            if ($f) {
                return $f->getFilename(); // Returns file name (not editable)
                return $f->getTitle();    // Returns file title (editable in file manager)
            }