We just upgraded from Umbraco 6 to Umbraco 7.1 and found out that replacing a media item no longer works? When selected a media item and 'Browse' for a new item and press 'Save' it is not uploading the file anymore like it used to do in Umbraco 6. Now we have to press 'Remove file(s)' and upload another image. But then the media id changes which we do not want. How can we actually replace an existing image? Or is this a bug in Umbraco 7.1?
The media Id does not change though, just the folder the media item is in might change. I know that can be undesirable if you refer to that folder directly but that's like hardcoding the ID in your templates. Make sure to query for the media item using @Umbraco.Media(someId) or @Umbraco.TypedMedia(someId)
Anyway, I've just tested this and it will definitely replace the media item if you just 1. "Choose file" and then 2. Save. So don't tick "Remove file(s)" and you're good to go.
When you do the workaround I described the media/xxxx/ changes indeed.
What you tested doesn't work correctly. Try this (filename is important):
Upload some image named a.png.
Open a.png with Paint and edit it a bit.
Upload again to Umbraco, notice there aren't any changes made to the original image.
But here it comes:
Rename a.png to b.png and it does get changed.
However, if you now rename b.png to a.png again and try to upload it, it doesn't replace the file (you get the old file).
This doesn't work correctly at all and was not present in Umbraco 6.
Can you use the @Umbraco.Media(someId) in the editor then? I need to insert an image in the text I'm writing. I don't think that was possible in Umbraco 6, but maybe in 7?
Replace media item in Umbraco 7.1
We just upgraded from Umbraco 6 to Umbraco 7.1 and found out that replacing a media item no longer works? When selected a media item and 'Browse' for a new item and press 'Save' it is not uploading the file anymore like it used to do in Umbraco 6. Now we have to press 'Remove file(s)' and upload another image. But then the media id changes which we do not want. How can we actually replace an existing image? Or is this a bug in Umbraco 7.1?
The media Id does not change though, just the folder the media item is in might change. I know that can be undesirable if you refer to that folder directly but that's like hardcoding the ID in your templates. Make sure to query for the media item using
@Umbraco.Media(someId)
or@Umbraco.TypedMedia(someId)
Anyway, I've just tested this and it will definitely replace the media item if you just 1. "Choose file" and then 2. Save. So don't tick "Remove file(s)" and you're good to go.
When you do the workaround I described the media/xxxx/ changes indeed.
What you tested doesn't work correctly. Try this (filename is important):
But here it comes:
However, if you now rename b.png to a.png again and try to upload it, it doesn't replace the file (you get the old file). This doesn't work correctly at all and was not present in Umbraco 6.
Ah yup, that's a breaking change in v7. I would recommend querying media instead of hardcoding the media urls (
@Umbraco.Media(someId)
)Can you use the @Umbraco.Media(someId) in the editor then? I need to insert an image in the text I'm writing. I don't think that was possible in Umbraco 6, but maybe in 7?
is working on a reply...