Copied to clipboard

Flag this post as spam?

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


  • Genc Kastrati 86 posts 401 karma points
    Feb 12, 2020 @ 12:50
    Genc Kastrati
    0

    Keeping old /media/ links when replacing a file on Umbraco 8

    Hi everyone,

    Is there a setting or a method to keep the old /media/1234/ links on Umbraco 8 when replacing a PDF for example?

    We have old links people reference to and would be great to keep them.

    Thank you! Genc

  • Steve Megson 151 posts 1024 karma points MVP c-trib
    Feb 12, 2020 @ 13:08
    Steve Megson
    101

    I don't think there's a setting to do it out-of-the-box, but you could implement it yourself. The media paths are created by an implementation of the IMediaPathScheme interface. By default, Umbraco 8 uses UniqueMediaPathScheme, but it also includes OriginalMediaPathScheme which generates the old numeric folder names.

    You could enable the original scheme with a UserComposer like

    public class MyComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            composition.RegisterUnique<IMediaPathScheme, OriginalMediaPathScheme>();
        }
    }
    

    However, that would use numeric paths for all new media items as well as preserving existing paths. If you want to use GUID-based paths for new media items, you could register your own custom implementation of IMediaPathScheme, combining OriginalMediaPathScheme's check of the previous URL with UniqueMediaPathScheme's approach to creating new paths.

  • Genc Kastrati 86 posts 401 karma points
    Feb 12, 2020 @ 16:02
    Genc Kastrati
    0

    Thank you so much Steve! I will give this a try and let you know how it works, also share how I've done it.

  • Genc Kastrati 86 posts 401 karma points
    Feb 17, 2020 @ 15:44
    Genc Kastrati
    0

    Thank you Steve! Your recommendation on how to switch to old paths worked.

    I tried figuring out how to implement IMediaPathScheme so it handles both, would you know where and how I would start? I know how to do it on version 7 but am a bit lost with 8 :(

    Thank you! Genc

  • Mia Kro 2 posts 72 karma points
    Feb 13, 2020 @ 20:42
    Mia Kro
    0

    Hi there!

    Had the same issue. Turns out v8 will preserve the media/x/ path if you:

    remove link image

    click the "Remove file(s)" link below your document and then upload the updated document (using the same file name).

    Note: if you are working in multiple environments, you'll need to completely delete the file from the Live environment before you queue the updated document for transfer. You may encounter errors otherwise. At least, I have.

    Hope this helps! Cheers, Mia

Please Sign in or register to post replies

Write your reply to:

Draft