Copied to clipboard

Flag this post as spam?

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


  • fred 2 posts 72 karma points
    Feb 02, 2022 @ 10:02
    fred
    0

    displaying an image in my template (U9)?

    Hello,

    I am trying to display an image in my template in U9. I am using this command:

    <img src="@Model.Image.MediaItem.Url"/>
    

    But I only get an error:

    'MediaWithCrops' does not contain a definition for 'MediaItem'
    

    in the CMS, the field Image is a Media image picker.

    What did I do wrong? =/

    Any help would be much appreciated. Thanks in advance!

  • Owain Jones 65 posts 437 karma points MVP 5x c-trib
    Feb 02, 2022 @ 14:49
    Owain Jones
    0

    Try this:

    <img src="@Model.Image.Url()"/>
    
  • fred 2 posts 72 karma points
    Feb 03, 2022 @ 06:35
    fred
    0

    Hi, thanks for replying to this.

    I still get an error with your suggestion:

    'NewsArea' does not contain a definition for 'Image' and no accessible extension method 'Image' accepting a first argument of type 'NewsArea' could be found (are you missing a using directive or an assembly reference?)
    
  • 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