Copied to clipboard

Flag this post as spam?

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


  • Danny dineen 17 posts 96 karma points
    Jul 11, 2018 @ 20:02
    Danny dineen
    0

    I understand the correct way to reference media files so when media files are replaced no broken links will occur. This is fine for code that runs from an Umbraco MVC view. The issue I am facing is that our editors wish to upload media files and distribute the media link for use in other distribute content mediums that Umbraco does not control. When a media file in Umbraco is replaced the numerical folder is changed and that will break all distributed links to that media file outside of Umbraco.

    Is there a special way to handle replacing media files in Umbraco so that the URL will not change at all? For now we are using the URL tracker plug in and creating redirects for any updated and distributed media links; as a work around.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jul 11, 2018 @ 20:10
    Jan Skovgaard
    101

    Hi Danny

    If I understand the issue correctly then I think you will actually need to find the media item in the media section and click on "Remove file" and then upload the new file, which will replace the old one. The new file will of course also need to have the same file-name as the old file that is being removed has. That way the url should remain the same and the file will be uploaded into the same id named folder.

    But it's a bit of a tedious process if it's something that needs to be done for many files of course.

    /Jan

  • AIDR Online 2 posts 72 karma points
    Aug 10, 2018 @ 06:19
    AIDR Online
    0

    Hi Jan, this doesn't work unfortunately. The link listed under the "Info" tab remains the same, but results in a 404. A new URL with a new number is created for the updated version, and we still have to manually update wherever it's linked on the website.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Aug 19, 2018 @ 18:05
    Jan Skovgaard
    0

    Hmm - Ok, so I just did some investigation on this and here is what I learned.

    If you're using the grid to insert an image then you're in fact right that the image change will not happen if you swap the image on the media item. I had to also re-select the image in the grid.

    However if one is using a media picker not using the grid then the updated image is visible once it's been swapped and the page has been refreshed.

    Even though as you say that the url does not change for the item, the correct url is being fetched in the last scenario.

    I'd say that the missing change of the links in the info tab is a bug and perhaps that's why the grid image is not automatically being updated.

    I'll try to ask about this in the Gitter chat to figure out whether to report this scenario as a bug or not.

    EDIT: I did this test on Umbraco 7.11.1 - Don't know if the behavior is the same on older versions but I suspect that it probably is. And I'm 99% certain it's the same on 7.12 :)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Aug 20, 2018 @ 10:50
    Jan Skovgaard
    0

    Ok, so a quick follow up!

    I just tested this on an older Umbraco version (7.7x) and when I swap the image then the url on the "info" tab does in fact change too.

    So in some version after the 7.7 release this bug has been introduced. Perhaps it happened after the "Properties" tab was renamed to "Info" for some weird reason :)

    However the image in a grid editor does not change. So that might either be expected behavior or another bug.

    I hope it all makes sense - I'll file an issue about this and linke to it from here at least.

    EDIT: The bug is reported here now http://issues.umbraco.org/issue/U4-11587

    /Jan

  • Danny dineen 17 posts 96 karma points
    Jul 12, 2018 @ 23:42
    Danny dineen
    0

    Thank you for your answer.

    I wish there was a way we could move a file into a physical media/{id} folder to recover the path of files when the correct procedure is not followed; from within Umbraco.

  • Arun 136 posts 369 karma points
    Dec 06, 2019 @ 12:52
    Arun
    0

    Can we use code to replace a file in Umbraco media? So that the reference to the file shouldn't get broke.

  • croban 25 posts 96 karma points
    Dec 11, 2019 @ 09:38
    croban
    0

    I have same problem, it is not possible to replace existing media file without changing ID - e.g. /media/ID/filename.pdf. Every time new ID will be generated (same filename, replace) means it is not possible to replace file without URL change. That is huge problem, because customers communicate some PDF Links to other media and afterwords they can not replace that file.

  • Arun 136 posts 369 karma points
    Dec 31, 2019 @ 05:53
    Arun
    0

    It is Possible

    string filePath = $"D:\\Temp\\testingFile.pdf"; //Path of file to be replaced, try next way if this doesnt works
    //string filePath = System.IO.Path.Combine(@"D:\\TestFolder\\", "testing.pdf"); 
    
    var fileName = Path.GetFileName(filePath );
    using (var fileStream = System.IO.File.OpenRead(filePath ))
    {
        var mediaService = ApplicationContext.Current.Services.MediaService;
        var mediaFile = mediaService.GetById(existanceFlag);
        mediaFile.SetValue("umbracoFile", fileName, fileStream);
        mediaService.Save(mediaFile);
    }
    
  • croban 25 posts 96 karma points
    Dec 31, 2019 @ 08:24
    croban
    0

    Yes, that is working if you are doing it programmatically, but try to achieve that over cms ui.

  • Marshall Penn 78 posts 258 karma points
    Jan 17, 2020 @ 15:15
    Marshall Penn
    0

    I have two Umbraco projects that are both 7.13.2 and in one of them the (/media/ID/filename.ext) ID increments when you replace the file, and in the other project it remains the same and does not increment. It is the same whether you replace the file with one with a different name, or the same name.

    Both projects use Azure for blob storage (all our sites do).

    In both cases i replace the file by just using the file picker (Browse..) and then save.

    I am thinking that a plugin might be responsible for the differing behaviour - the one where the ID increments has USync installed, but i have not found a definite reason why the behaviour is different between them as yet.

  • croban 25 posts 96 karma points
    Jan 17, 2020 @ 15:24
    croban
    0

    Thx, this hint with usync is great, I have to look for this, because we have usync installed.

  • Sam Stuewe 12 posts 82 karma points
    Jun 02, 2020 @ 22:23
    Sam Stuewe
    0

    Hey there. Did you ever nail down what may be causing this?

    I have a client who is experiencing a very similar (the same?) issue.

    Namely, if they go to update a PDF file with an updated version, if they specify the same file name, the new version of the file is not uploaded; and if they specify a different file name, the path to the file, of course, changes, so the links would be broken.

    I'd love to see a fix for this that doesn't involve moving to a newer version of umbraco (they're stuck on a reasonably old 7.x release), so I'm hoping you managed to figure it out. :)

    All the best,

    -Sam

  • Marshall Penn 78 posts 258 karma points
    Jun 03, 2020 @ 07:49
    Marshall Penn
    0

    No, im afraid the mystery remains ....

  • Kieran O'Dwyer 12 posts 82 karma points
    Jul 21, 2020 @ 09:14
    Kieran O'Dwyer
    0

    This make's replacing heading images across every page on a website impossible from a business perspective. The amount of time a business would need to allocate to manually replace every image is just horrendous. This is such a fundamental flaw.

    Say you were presented with a website with image resource sizes of 1.5Mb for just a handful of images and you wanted to compress, use a different file format but keep the image name the same.

    When an Editor chooses to replace an image in the media section, the first thing I would expect as that user is for all occurances of that image to change everywhere. Isn't that the point of including such a feature?

Please Sign in or register to post replies

Write your reply to:

Draft