8

We have 3 (near identical) Sitecore sites on a development server and 2 out of the 3 fail to resize the images using the inbuilt Sitecore query string parameters.

Example URL: /~/media/59274CA8941B4540B7B1A6C0FEAE9F84.ashx?w=300&h=30

The media image is returned but it fails to resize the image.

So far I've tried file permissions, config diff (web.config and showconfig.aspx) but nothing obvious stands out.

I'm thinking its something in IIS but cannot think what.

  • 1
    Try removing \App_Data\MediaCache folder and resetting IIS – Marek Musielak Oct 19 '16 at 14:31
13

As of Sitecore 7.5+ (applies to the latest 7.2 versions as well), Sitecore introduced a media request protection for image resizing (to make sure an attacker can't overload your server with image resize requests)

In this case you have two options:

  1. Add a media hash to the resizing requests, like that:
    Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl (
                           Sitecore.Resources.Media.MediaManager.GetMediaUrl(
                               myMediaItem,
                               new MediaUrlOptions()
                               {
                                   Language = Context.Language,
                                   Width = 100,
                                   Height = 75
                               }))
  1. Disable media request protection (not recommended)

You can find more details in this blog post: http://kirkegaard-at.blogspot.sg/2015/06/media-hash-and-resizing.html

Your Answer

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