0

We would like to bind image component src thorough programming and would like to get Hash value as well.

Need this output :

<img src="/-/XXXXXX?h=192&amp;w=192&amp;hash=98HGR761E4B00739EF6E206F74C443AE" alt="Two people working" width="192" height="192" data-variantitemid="{KH6HFU6F-KUT2-452B-B519-D60393CB1F56}" data-variantfieldname="Image">

We are getting data from content api and bind them on a view. However, when we are trying to bind data for the image , we are not able to get above mentioned attribute.

0

What you need to do is to call Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl:

var url = MediaManager.GetMediaUrl(mediaItem, options);
var protectedUrl = HashingUtils.ProtectAssetUrl(url);

This will calculate the hash value based on the parameters from the url.

2
  • I will try this and can we bind image component src with custom url ? Sep 14 at 13:46
  • You should add your code to the question. It's not clear how you work with images and api. Sep 14 at 13:49

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.