Copied to clipboard

Flag this post as spam?

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


  • ThomasBrunbjerg 86 posts 178 karma points
    Aug 15, 2017 @ 10:38
    ThomasBrunbjerg
    0

    Insert image from media picker into CSS background image property

    I am trying to insert a image from the media archive as a background image to my promo banner. This is my current code:

    style="background-image: url('@Model.Content.GetPropertyValue<IPublishedContent>('promoBackgroundImage').Url')"
    

    But this returns a compilation error with this message: "The best overloaded method match for 'System.Tuple.Create

    I used the code example from the official documentation.

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Aug 15, 2017 @ 11:11
    Dan Diplo
    1

    Maybe try using double quotes and wrapping in brackets:

    style="background-image: url('@(Model.Content.GetPropertyValue<IPublishedContent>("promoBackgroundImage").Url)')"
    
  • ThomasBrunbjerg 86 posts 178 karma points
    Aug 15, 2017 @ 11:20
    ThomasBrunbjerg
    0

    Thanks, that worked!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies