image alt text

Permalink Browser Info Environment
Hi,

Is it possible to let DC check if an image alt text is filled in the edit screen and if not that it loads the title attribute written in the file manager?

Thx!

Type: Discussion
Status: New
xb385
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
Yes, this is possible. The exact code depends on the specific fields in your custom block, but here is an example (assuming the image is the first field in the block, and hence the name of the alt text field is "field_1_image_text"):

In the controller.php file, find the "view()" function, and add this code to it:

//if alt text is empty, use file's title attribute instead
if (empty($this->field_1_image_text)) {
  $file = File::getByID($this->field_1_image_fID);
  $title = $file->getTitle();
  $this->set('field_1_image_text', $title);
}

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.