Copied to clipboard

Flag this post as spam?

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


  • Luis Pedro 29 posts 151 karma points
    Aug 02, 2019 @ 15:38
    Luis Pedro
    0

    Extending property URL on media objects only

    Hi,

    How can I extend the media property URL so that instead of returning the relative path to media of the image

    object.Url = /media/123/filename.png

    it starts returning what I want

    object.Url = //mydomain.url/folder/media/123/filename.png

    Note. Only on media types, ... on ContentPickers, etc, shoud continue to return the relative url

    Thanks.

  • Amir Khan 1287 posts 2744 karma points
    Aug 02, 2019 @ 19:58
    Amir Khan
    0

    Do you mean globally or just in your views? If the latter, you can do the following when you query media.

    var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("imageAlias");
    if (typedMediaPickerSingle != null)
    {
        var imagePath = @Request.Url.Scheme + "://" + @Request.Url.Host + @typedMediaPickerSingle.Url;
        <img src="@imagePath">
    }
    
  • Luis Pedro 29 posts 151 karma points
    Aug 02, 2019 @ 20:19
    Luis Pedro
    0

    Globally, without having the need to go trough all views and change.

    Sorry, forgot the term, basically, I want to override the .URL property on the media objects by my own result.

    source code returns

    image.Url = /media/1234/filename.png

    and I what to keep the same property usage on the view (without having to change my views), but to return my override result, like:

    image.Url = https://mydomain.com/folder/media/1234/filename.png

    Thanks,

Please Sign in or register to post replies

Write your reply to:

Draft