Copied to clipboard

Flag this post as spam?

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


  • Kdingle1 5 posts 25 karma points
    Sep 06, 2023 @ 15:48
    Kdingle1
    0

    Media file replacement changing the URL and breaking hardcoded links

    In umbraco 11 - when you replace a media file, it will change the URL to the new media file name and therefore break any hardcoded links to the original file.

    expected: User wants to update a media file user opens media file in the media library - example: ' Error Test Image' in the testing folder' in with media library. https://cms.scouts.org.uk/media/q5jlmmou/error-test-image.jpg user 'removes file' user replaces image with another image user clicks save url for the image remains the same as before, but with the new image displaying All uses of the image (and the URL) remain

    actual: User wants to update a media file user opens media file in the media library - example: ' Error Test Image' in the testing folder' in with media library. https://cms.scouts.org.uk/media/q5jlmmou/error-test-image.jpg user 'removes file' user replaces image with another image user clicks save URL for the image URL changes to the new image URL All uses of the image (and the URL) are broken for hardcoded links

    Is it possible to have the URL remain the same?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 07, 2023 @ 08:05
    Huw Reddick
    0

    Why are you using hardcoded image urls?

  • Kdingle1 5 posts 25 karma points
    Sep 07, 2023 @ 11:00
    Kdingle1
    0

    We don't encourage it. Obviously we would prefer content producers to use the picker, but we do know that this doesn't always happen and some producers will use a link to the image instead.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 07, 2023 @ 11:04
    Huw Reddick
    0

    If they used the picker then this problem would not occur.

    It would require quite a bit of custom code to change the way the media items are saved, even if it were possible.

  • Kdingle1 5 posts 25 karma points
    Sep 07, 2023 @ 15:53
    Kdingle1
    0

    Thanks so much for clarifying.

  • Owain Jones 59 posts 389 karma points MVP 4x c-trib
    Nov 06, 2023 @ 12:46
    Owain Jones
    1

    Apologies for bumping this thread, but I just wanted to point out that this is possible, but you need to ensure that the filename is identical to the old filename.

    E.g. here's a GIF of me replacing a PDF with a PDF of the same name, but with different content, on Umbraco 12.3: Snap into a slim jim! As you can see, the URL is retained as the filename is the same.

    I have clients who regularly replace files in this manner, as they link files on external sites and don't/can't update those external URLs...

    But if a URL does change, then you can use something like the Skybrud Redirects package to easily create a re-direct.

    And yea, as Huw said, automating this would require a substantial amount of custom code 😬 (not worth it in my opinion, better to just make your content editors aware that they need to keep the filename the same)

Please Sign in or register to post replies

Write your reply to:

Draft