Copied to clipboard

Flag this post as spam?

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


  • ThomasBrunbjerg 90 posts 182 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 1554 posts 6205 karma points MVP 6x 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 90 posts 182 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