Quicksilver GetAssets<IContentImage> returns documents and images [12.16]

Vote:
 

Hi!

We have used the Quicksilver extension for getting images for a product. All of a sudden it also returns pdf files.

images = currentContent.GetAssets<IContentImage>(
                    _contentLoader,
                    _urlResolver,
                    Constants.DefaultProductImageUrl);

Externsion method:

public static IList<string> GetAssets<TContentMedia>(this IAssetContainer assetContainer, IContentLoader contentLoader, UrlResolver urlResolver, string defaultAssets)
    where TContentMedia : IContentMedia
{
    var assets = new List<string>();
    if (assetContainer.CommerceMediaCollection != null)
    {
        assets.AddRange(assetContainer.CommerceMediaCollection.Where(x => ValidateCorrectType<TContentMedia>(x.AssetLink, contentLoader)).Select(media => urlResolver.GetUrl(media.AssetLink)));
    }

    if (!assets.Any())
    {
        assets.Add(defaultAssets);
    }

    return assets;
}

Up until now the above code gave me only images. Has this function been updated?
The PDF is GenericData

[ContentType(GUID = "6ab524b7-0c98-4b67-bb5f-66d8090accd0")]
[MediaDescriptor(ExtensionString = "txt,pdf,docx,doc,xlsx,xls")]
public class GenericMedia : MediaData
{
    public virtual string Description { get; set; }
}

And images are ImageMediaData:

[ContentType(GUID = "20644be7-3ca1-4f84-b893-ee021b73ce6c")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png")]
public class ImageMediaData : CommerceImage
{
}

/Kristoffer

#204764
Jun 17, 2019 10:08
Vote:
 

MediaData implements IContentMedia. If you only want to get images, you can call with CommerceImage instead.

I have no idea why it "suddenly" happen to you

#204787
Jun 18, 2019 10:57
Vote:
 

My bad. We had some problems and modified the ValidateCorrectType() and there for a PDF was considered a valid image.

Thanks again!

#204790
Jun 18, 2019 11:13
* 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.