Per Nergård
Jan 7, 2025
  97
(1 votes)

ImageFile alt-description validation attribute

A customer wanted to improve their quality of having meta descriptive texts on all their published images but it was ok that it could take some time to get it into place (they are forced to review and republish pages on a regular basis) so thought that a validation attribute would do the trick.

I vaguely remebered that I did something like this a long time a go which I had (nov 2015) but that didn't handle images added in Xhtml-properties which was needed in this case. I found a solution that had solved a similiar problem but did handle it on actual rendering which used HtmlAgilitypack to handle the check for xthml-editors.

So I updated my validation attribute and I have published it as a Gist. ImageValidatorGist.

The validation attribute checks contentreference, ContentArea and XhtmlEditor properties for images and check if they have a description property with value and if not returns an error. Since a image-file added to a XhtmlEditor gets the filename name as alt-text we need to compare the alt-text to the file-name and if equal we interpret that as not set even if the image file it self might have a descripton set.




Jan 07, 2025

Comments

Please login to comment.
Latest blogs
Custom Sitemap.xml generator in Optimizely CMS 12

This is a step by step guide to generate sitemap.xml file for all the sites in optimizely cms 12. The sitemaps are generated under wwwroot/sitemaps...

sunylcumar | Jan 7, 2025

Build a headless blog with Astro and Optimizely SaaS CMS Part 3

It is finally time to explore my basic blog example powered by Astro and Opti SaaS CMS. For those new to the series, you may want to read parts one...

Jacob Pretorius | Jan 6, 2025

How to add an Admin Mode add-on in Optimizely CMS12

How to add a new add-on with navigation and unified stylesheet

Bartosz Sekula | Jan 2, 2025 | Syndicated blog

Managing Your Graph Conventions

Recently, Optimizely released a Conventions API for manging how various fields on your CMS content are indexed by the Graph. This is an extremely...

Ethan Schofer | Dec 31, 2024

SaaS CMS and Visual Builder - Opticon 2024 Workshop Experience

Optimizely is getting SaaSy with us…. This year Optimizely’s conference Opticon 2024 took place in San Antonio, Texas. There were a lot of great...

Raj Gada | Dec 30, 2024