Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Simon 2 posts 72 karma points
    1 week ago
    Tom Simon
    0

    Can I add an altText property to the Image media type?

    Hello, Completely inexperienced with Umbraco and in web development in general, so I hope my question isn't silly and that I manage to get it across: I want to add an altText as a mandatory property to the Image media type, so that whenever the content creator uploads an image they're prompted to input a description (which I can later pass into the 'alt' attribute in my templates). Adding the property to the media type is easy, but it doesn't have any effect on the image upload process - there's no prompt to input text. Is there a way to make it work (or maybe some better way to make adding a description mandatory as part of the upload process)? Thanks!

  • Ahmed Adel 2 posts 73 karma points
    1 day ago
    Ahmed Adel
    1

    Hello Tom,

    From Umbraco backoffice, you can click on Settings, Open media type, then select Image

    enter image description here

    Them click on Add Propery, enter a name for it "let's assume Alt Text", then click on Select Editor enter image description here

    Assuming it will be a text input, Search for "text" and then select text string, then click on Submit.

    enter image description here

    After submitting you will notice that the property has been added to the Image type, Click save

    enter image description here

    Now all your existing images and newly created images will have the field Alt text

    enter image description here

    After that all what you need is to read this property in your template which most probable will be "altText" if you named the new property "Alt Text", notice the text in front of the lock icon under the property name field.

    Just read the property in the template and put its value in the alt tag in the image tag

    enter image description here

  • Tom Simon 2 posts 72 karma points
    19 hours ago
    Tom Simon
    0

    Hello Ahmed, thanks for the detailed reply. Create image dialogue box From what I can tell, this dialogue box only presents within the Media section of the Umbraco back office. However, when I use a media picker in the Content section to upload an image this dialogue box doesn't appear, the image is simply added to the folder. I expect my users to use the media picker almost exclusively, so the fact that the property is visible in the Media section is not really useful. Also, not only is this property difficult to get to, it's requirement as 'mandatory' is bypassed by uploading the image in the Content section. It seems like a sort of bug, doesn't it? I guess I could work around it by using compositions comprising a media picker and a text box instead of embedding the text box into the media picker. Any other ideas? By the way, I'm using Umbraco 13.5.1, maybe this problem has been fixed in v14?

    Thanks again, Tom

Please Sign in or register to post replies

Write your reply to:

Draft