10

Sitecore flags up empty Alt tags but it still lets users save them without setting the Alt tag. Is there an easy way to enforce that this is done for all new images?

enter image description here

I know I could write a custom validator like so: https://techmusingz.wordpress.com/2014/11/04/enforce-alt-text-for-image-fields-in-sitecore/

But Ideally I'm looking for a way of doing this out of the box with the rules engine or something like that and prevent users saving/uploading images without Alt text.

-- Update --

One problem I've seen related to this is that the standard image uploader in the media library doesn't allow the user to add alt text during upload and so even with a rule to enforce alt tags on save this doesn't prevent initial alt tags being empty on save.

Thankfully I came across this pipeline example which will run on load and add a default alt text based on the image title:

https://sitecorejunkie.com/2014/06/18/set-default-alternate-text-on-images-uploaded-to-the-sitecore-media-library/

Neat idea but I haven't implemented it yet.

Further info: Sitecore 8.1 Update 2.

  • Love the Rules Engine! Before answering, describe how you want this to work. Do you want to prevent the image from displaying? Do you want to prevent the user from saving? Do you want to prevent publishing? etc. IMHO the simplest solution that leverages the most OOTB stuff will be preventing publishing – Zachary Kniebel Oct 14 '16 at 15:53
  • @ZacharyKniebel I like the idea of preventing publishing but this wouldn't be very visible to content editors and I could see lots of requests saying 'I can't see my images and I don't know why'. So instead I think I'd rather see an error when they try and save the image. I'll update my question above. – Adam Seabridge Oct 14 '16 at 16:00
  • Fair enough - I think that you're going to have to tap a little bit of custom code though, in order to get what you want. – Zachary Kniebel Oct 14 '16 at 16:01
  • 1
    Are you sure users are allowed to save these? I think the only reason you can bypass the validation set for these, is with admin rights. – Mark Cassidy Oct 14 '16 at 16:24
  • Sitecore a has a couple of ways to upload images, namely individual and bulk uploads. Just something to be aware of so you can cater for both scenarios – Steve Newstead Oct 16 '16 at 14:19
13

You are able to set the required validation item rule item to FATAL ERROR in Sitecore. This is the highest level of validation. This setting prevent the user to save the item with validation error.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.