Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Benjamin Richardson 2 posts 72 karma points
    Jan 15, 2024 @ 21:33
    Benjamin Richardson
    1

    Query string image resize not working on umbraco 12

    Hi! On Umbraco 12 I'm running into an issue resizing images with query strings. In previous versions of Umbraco I could resize an image in a razor template like so:

    <img src="/media/e2sjgvly/200410983-001.jpg?width=400" />
    

    Which would then produce a version of the image with a width of 400px. However, in Umbraco 12 this query string only seems to work sporadically, and more often than not returns an image unchanged. See an example below:

    screenshot of a browser window containing an image with the query string width 400 applied. The image remains full size.

    We tried upgrading to the latest version of 12 - 12.5.6. Still the same issue.

  • Charles Campbell 2 posts 73 karma points
    Feb 28, 2024 @ 15:15
    Charles Campbell
    2

    Found a solution at link below that worked for me.

    https://our.umbraco.com/forum/using-umbraco-and-getting-started/109573-getcropurl-doesnt-resize-the-image-on-umbraco-10#comment-341339

    In Startup.cs if you either remove this line (OR change):

    app.UseStaticFiles();
    

    to:

    app.UseWhen(context => !context.Request.Path.StartsWithSegments("/media"), appBuilder => appBuilder.UseStaticFiles());
    

    and rebuild solutuion. Works like a charm!

  • Stephen Garside 3 posts 75 karma points
    Mar 19, 2024 @ 07:12
    Stephen Garside
    1

    Thanks for posting this - after a few hours of searching I found this and it solved my issue.

    I think my issue stemmed from creating a new .net core solution in Visual Studio and then adding Umbraco 13 to it vs creating it as an Umbraco 13 solution right from the start.

    The difference in the Program.cs file between the two install paths is this line only (for URL re-writing).

    I searched for "Umbraco 13 ImageSharp.Web not working" , "Umbraco 13 Image Cropping not working" etc, with not much being returned.

    Hopefully all my keyword stuffing above will help others find your solution!

    Thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft