Try our conversational search powered by Generative AI!

IVFileData not returning AltText?

Vote:
 

Hi, I seem to be having issues returning the alt text for an image stored in EPiServer.

I'm storing an image in the cms in an ImageVaultImage control and inputting the desired alt text at this point.

However, this alt text doesn't seem to be returned when I try to read the IVFileData in:

public static string GetImageAltText(string imageURL)
{
    string altText = "";

    try
    {
        IVFileData fileData =                     IVDataFactory.GetFile(IVUrlBuilder.ParseUrl(imageURL).Id);

        altText = fileData.AltText;
       }
    catch (Exception)
    {
    }

    return altText;
}


Am I approaching this all wrong?

#20646
Jun 06, 2008 18:20
Vote:
 

Hi Adam. 

I took a quick look in the SDK and found the explination for the AltText property:

AltText - Gets the meta data that is used as alternate text for the file if it´s enabled in ImageVault.

 So I think this will only return the meta data that an image has. If you are using an ImageVaultImage property, I have a way you can get the alt text out of the property.

 string altText = ((string)PageData["PictureProperty"]).Split(new char[] { '~' })[2];

 I am not sure if this is the right way to do it, but it will solve your problem :)

 

BR,

Tore 

#20647
Jun 08, 2008 17:27
Vote:
 

Ah, I did ponder doing it that way, cheers!

It's not perfect, but will have to do - It'll just mean hoping that the image URLs don't change anytome soon.

#20652
Jun 09, 2008 10:05
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.