Copied to clipboard

Flag this post as spam?

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


  • Corné Strijkert 80 posts 456 karma points c-trib
    Oct 28, 2021 @ 13:56
    Corné Strijkert
    0

    How to generate hash in media URL

    Hi all,

    Does somebody know how the 'hash' was generated for media URLs?

    For example /media/yfemfx5x/room-on-fire.jpg

    I need to convert old /media/{int}/file.png v7 formats to /media/{hash/}file.png v8+ formats to make sure that the media URLs are unique. Thats important, because I use uSync content edition to move content/media from old environment to different umbraco env. With the {int} ID's I can't make sure that there are no collisions when importing media (already existing media IDs).

    Thank you!

  • Kevin Meilander 82 posts 408 karma points c-trib
    Oct 29, 2021 @ 16:33
    Kevin Meilander
    100

    It looks like the logic is based on combining item guid, and the property guid, and converting it into a base32 string.

    here is the method:

    https://github.com/umbraco/Umbraco-CMS/blob/5bfab13dc5a268714aad2426a2b68ab5561a6407/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs#L22 (there are a few other implementations, but i think this is the default one)

    It's called from:

    https://github.com/umbraco/Umbraco-CMS/blob/5bfab13dc5a268714aad2426a2b68ab5561a6407/src/Umbraco.Core/IO/MediaFileManager.cs#L108

    I'm not sure if there's an easy way to migrate things form the old path to the new one, but you could probably write a script that leverages the same path logic.

  • 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