Per Nergård
Nov 29, 2015
  2893
(1 votes)

Validation of media file attributes

As all of you know media files in EPiServer are IContent which lets us add properties to handle for example meta data. This is great but how do we make the editors fill in those fields...

I guess that it depends a lot of what type of target audience you have as well as what fits the site editors. 

The below could be alternatives to consider:

  • You don't do anything at all
    Obviously not recommended.

  • You add fallbacks in the code so atleast some is used.
    Could be ok, but "real" meta data is better.

  • You make the field required and disable auto publishing of mediafiles.
    I don't like this because it seems a bit to hard on the editors. It should be easy to add a bunch of images without needing to process them all at once.

  • You try to add som other validation before publishing pages or blocks that use media files.
    If you block publishing I guess this is basically as hard on the editors as the previous option but to me it still feels as a better way.

To solve the last option I did a small validation class that checks all ContentReference and ContentArea properties on a page, checks if it's an image and then checks if the Copyright attribute is empty or not (Did this in the Alloy demo site). If youn're using Url properties with a media file UIHint it's easy to add.

You can get the code over at Gist. You can see the result below where I added a image with no Copyright info into the Teaser Image property.

Image ValidateImageFileExample.jpg

Nov 29, 2015

Comments

Please login to comment.
Latest blogs
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 tim...

Per Nergård | Jan 7, 2025

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