Remove query string from images in Media Library

Stephen Herz asked on November 17, 2016 01:31

Google PageSpeed is lowering my score because of the query string ?ext=.jpeg added to most of my images. The suggestion is to "Remove query strings from static resources"

Most of my image URLs look like this: Media/Images/Banners/Our-Approach.jpeg?ext=.jpeg

Is there any way to stop adding the query string? I can remove it in the media library but don't want to go thru 100's images manually.

Recent Answers


Anton Grekhovodov answered on November 17, 2016 05:31

Hi Stephen,

It's weird that you have extension query parameter in non-permanent image URL, usually it is in permanent media files URLs(/getmedia/) and I think there isn't out of the box functionality to remove it. Using permanent URLs has a very big advantage (Responsive images in Kentico)

Anyway, to remove query parameter, you can create custom output filter where you will find image urls and remove the parameter Making custom modifications to output HTML

0 votesVote for this answer Mark as a Correct answer

Laura Frese answered on November 17, 2016 17:22

Maybe you could remove it in the transformation?

<% Eval("MyImage").ToString().Substring(0,Eval("MyImage").ToString().LastIndexOf("?")) %>
3 votesVote for this answer Mark as a Correct answer

Amit Srivastava answered on November 18, 2016 08:53

Hi Stephen,

Whenever you are browsing media files from media libraries using page type at that time you can remove ?ext=.jpeg from media libraries URL then you will get media files without ?ext=.jpeg extension. You can try it from this way or you can also use transformation method whatever suggested by Laura.

3 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.