Copied to clipboard

Flag this post as spam?

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


  • shilpanjali 15 posts 85 karma points
    Aug 18, 2023 @ 11:01
    shilpanjali
    0

    Update media without media folder path changed in Umbraco 10 after migrating from Umbraco 7.

    Hi, I have migrated my Umbraco website database from version 7 to Umbraco 8 and now to 10. But now in Umbraco version 10 while I am updating a media from the Umbraco backend, the media updates on to new folder path. And this happens only on the media which is migrated from Umbraco 7 Version. Media folder names with numbers. (Original media path scheme) I would want the media image to be updated on the same path. Any help here is appreciated please.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Aug 18, 2023 @ 16:50
    Marc Goodson
    0

    Hi Shilpanjali

    In V7, the methodology to generate the unique part of the path between /media and /thefile.jpg used to be an incremental number...

    eg /media/132443/thefile.jpg

    When new media items were uploaded, there was code to find all the folders within media, find the largest number and add 1

    In Azure Blob Storage though, this was super slow! and so the idea with V8 was to move to a uniquely generated Id based on the guid of the media item...

    Existing files were left on their original path so as not to create broken links when somebody upgraded...

    ... but all new uploaded images follow the new pattern... but this is 'configurable'.

    This part of the MediaFileSystem has been abstracted into an implementation of IMediaPathScheme https://docs.umbraco.com/umbraco-cms/extending/filesystemproviders#mediapath-scheme

    The new path scheme is called the 'UniqueMediaPathScheme' - you can see the implementation here: https://github.com/umbraco/Umbraco-CMS/blob/d7cbd9bf619ef22aeb2d7fa6bd9b94f1e8478e0b/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs#L9

    The v7 scheme was called 'OriginalMediaPathScheme' and this was removed from V9 - you can see the implementation here: https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs

    So in theory you could 'create' your own implementation of IMediaPathScheme, that uses the propertyGuid to retrieve the existing stored value, and if it contained a media item path that was an integer, use this as the Path, but if it were a new item, then utilise the new UniqueMediaPathScheme mechanism to create any new uploads with the more robust guid approach, eg don't just implement the OriginalMediaPathScheme!

    or at least that's the theory!

    regards

    marc

  • shilpanjali 15 posts 85 karma points
    Aug 22, 2023 @ 06:18
    shilpanjali
    0

    Hi Marc, Thank you for your response. Could you please guide on how this implementation of mediapathscheme can be overridden in umbraco 10 . .net core solution to get the previous media path while updating the media. If there is any reference to code that will be really helpful.

  • shilpanjali 15 posts 85 karma points
    Sep 06, 2023 @ 07:02
    shilpanjali
    0

    Hi, Any response here would be helpful !

  • shilpanjali 15 posts 85 karma points
    Sep 27, 2023 @ 07:20
    shilpanjali
    0

    Hi,

    I have migrated my website from Umbraco 7 to 10, But media uploaded in Umbraco 7 changes the path and stores in new path when updated from umbraco backend media Section. eg: media/ahgdsah/test.jpeg instead of updating under media/1110/test.jpeg. Due to this media path present on any content page needs to be updated manually. Is there a solution on how the umbraco 7 media can be updated in Version 10 without path being changed. Please help.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Nov 12, 2023 @ 21:51
    Marc Goodson
    0

    Hi shilpanjali

    Just read a blog post with an example IMediaPathSchema example in that might provide some inspiration...

    https://owainjones.dev/blog/how-a-custom-imediapathscheme-came-to-the-rescue-for-our-migrated-media/

    Regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft