Copied to clipboard

Flag this post as spam?

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


  • Pedro Mendes 53 posts 258 karma points
    Nov 28, 2023 @ 12:51
    Pedro Mendes
    0

    Media is not appearing in frontend

    Hey there all,

    I have a strange issue. Somehow, all my media seems to be broken for the frontend.

    Wherever I have an image, the image tag appears <img> only.

    A refresh on the cache and memory won't do anything. A save on the media fixes it.

    Issue is: I have 1000 medias and saving each and everyone of them to make sure it shows in the frontend is time consuming and failable.

    Has anyone ever come across this issue? If you did, how did you fix it?

    Thanks

  • Alex Skrypnyk 6148 posts 24097 karma points MVP 8x admin c-trib
    Nov 28, 2023 @ 23:28
    Alex Skrypnyk
    1

    Hi Pedro,

    How do you render images? Can you show the code? What Umbraco version are you using?

    Alex

  • Pedro Mendes 53 posts 258 karma points
    Nov 29, 2023 @ 01:05
    Pedro Mendes
    0

    Thank you for replying Alex!

    I'm using Umbraco 12.3.2 and the code is this

    <picture class="newsCard__media">
       <source media="(max-width:768px)" srcset="@Model.PageDefinitionImage?.GetCropUrl("highlighted", UrlMode.Absolute)">
       <img src="@Model.PageDefinitionImage?.GetCropUrl("highlighted", UrlMode.Absolute)" alt="@Model.PageDefinitionImage?.Name">
    </picture>
    

    PageDefinitionImage is a Umbraco.Cms.Core.Models.MediaWithCrops

    This is what it being rendered

    <picture class="newsCard__media">
       <source media="(max-width:768px)" srcset="null">
       <img src="null" alt="null">                        
    </picture>
    

    because, somehow, the PageDefinitionImage is null. If I go to Media section and save it, it will appear :\

  • Danine Noble 82 posts 368 karma points
    Nov 29, 2023 @ 17:41
    Danine Noble
    1

    Does it work if you do not set the UrlMode to be absolute?

    Just: GetCropUrl("highlighted")

    I found this little discussion that mentions setting forwarded headers if the absolute url isn't being set correctly -- but don't know if its relevant to your situation...

    And you're saying that it's working now just after saving the media item? Was this a new behaviour after updating Umbraco or a migration? 1000 individual saves would be terrible. Could find or write something to go through and save all media items.

  • Pedro Mendes 53 posts 258 karma points
    Nov 29, 2023 @ 19:53
    Pedro Mendes
    0

    Thanks for the info Danine.

    I'll try it and get back to you

  • Pedro Mendes 53 posts 258 karma points
    Dec 03, 2023 @ 02:17
    Pedro Mendes
    0

    Hey Danine,

    That was not not the issue but Nik provided the solution, it was Umbraco fault, shame on them 😁

  • Danine Noble 82 posts 368 karma points
    Dec 04, 2023 @ 15:30
    Danine Noble
    0

    So it was update related ^^ Well! It's always nice when it's a simple resolution; can't complain too much about that haha! ;D

    Glad it was resolved! Nik's a rockstar!

  • Nik 1610 posts 7236 karma points MVP 7x c-trib
    Dec 01, 2023 @ 10:00
    Nik
    101

    Hi Pedro,

    Please update to the latest version of v12 (I think there is 12.3.3) there was a know issue that resulted in media not loading into the cache properly. The fixes started in v12.3, but I don't think it was fully fixed untill 12.3.3 so it's worth the update.

    https://our.umbraco.com/download/releases/1232 - see the issue there, I think there is "another" related fix in the 12.3.3 release.

    Thanks

    Nik

  • Pedro Mendes 53 posts 258 karma points
    Dec 03, 2023 @ 02:16
    Pedro Mendes
    0

    Hey there Nik,

    That was the issue!! Thank you so much :D

Please Sign in or register to post replies

Write your reply to:

Draft