Copied to clipboard

Flag this post as spam?

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


  • Allan Svelmøe Hansen 25 posts 136 karma points
    Mar 05, 2018 @ 11:30
    Allan Svelmøe Hansen
    0

    Get CropUrl without HttpContext

    Hi.

    I'm using Hangfire to start some long running background jobs in which I (amongst other things) want to try and use the cropped url for images/media. However, seeing as I do not have access to the HttpContext and UmbracoHelper in these jobs, I cannot just use the IPublishedContent extension GetCropUrl.

    I have noticed it seems I have access to the ApplicationContext and Services, so is it possible to get a crop url via the API in some other manner?

    Thanks in advance.

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Mar 05, 2018 @ 12:12
    Matthew Wise
    0

    Hi Allan,

    GetCropUrl wraps around ImageProcessor so if you know the settings you want to use you could do so directly

    http://imageprocessor.org/imageprocessor/imagefactory/

    Matt

  • Allan Svelmøe Hansen 25 posts 136 karma points
    Mar 06, 2018 @ 07:10
    Allan Svelmøe Hansen
    0

    Hi. Thanks for the reply, but accessing the ImageProcessor seems to be to do the actual cropping, which I'm not interested in doing manually.

    I'm trying to determine what URL an IMedia loaded from - for example - the MediaService would get when I do not have access to the IPublishedContent.GetCropUrl("cropsetting") extension method. The cropping etc will still be done normally.

    It seems there is a GetCropUrl which is extending on a normal string (URL) so I suspect it should be completely possible; however - I cannot seem to find documentation regarding getting the URL out of IMedia and getting the CropSettings from a Crop Alias

  • Allan Svelmøe Hansen 25 posts 136 karma points
    Mar 06, 2018 @ 07:51
    Allan Svelmøe Hansen
    0

    I dug into the code and actually found an obsolete ImageUrlProvider which seems to be able to do much of what I would like to do (GetImageUrlFromMedia).
    However it's not mentioned what will be replace this obsolete method/Provider?

Please Sign in or register to post replies

Write your reply to:

Draft