I have a Page with Media coupled with it by MediaPicker (so I have both Page node id and media file id). Can I somehow have some impact on the url to media? NiceUrl doesn't seem to work (returns empty). The media gets url like: site.com/media/987/file.pdf. I would like it to be for example: site.com/file.pdf . Is messing with the URL rewrite the only way to achieve that?
you would need to use a URL rewriter to achieve this. Umbraco will always store the ID of the media element as part of the path (either a folder or in the file name), otherwise how could you ensure uniqueness across the site?
If file.pdf was in the root and someone else tried to upload a file called file.pdf it would replace the existing one and 'update' all links to it.
Look, I know you want to help me, but, with all the respect, you didn't said anything new.
It's obvious that cms has to somehow find the file. It's obvious that id needs to be used. I am aware of that. I am also aware of implications that could have on existing files put outside the media.
I asked a question whether it's possible to have impact on that without url rewrite and the answer isn't that obvious. That's because umbraco has several undocumented features and hacks and that could be one of them.
I've not done/tried this myself, but you could try to add a new property to your media item with alias = umbracoUrlAlias or alias = umbracoUrlName. I know it works for content items, so it might also work on media items (I wouldn't know why atm)
NiceUrl for Media file?
I have a Page with Media coupled with it by MediaPicker (so I have both Page node id and media file id). Can I somehow have some impact on the url to media? NiceUrl doesn't seem to work (returns empty). The media gets url like: site.com/media/987/file.pdf. I would like it to be for example: site.com/file.pdf . Is messing with the URL rewrite the only way to achieve that?
you would need to use a URL rewriter to achieve this. Umbraco will always store the ID of the media element as part of the path (either a folder or in the file name), otherwise how could you ensure uniqueness across the site?
If file.pdf was in the root and someone else tried to upload a file called file.pdf it would replace the existing one and 'update' all links to it.
Look, I know you want to help me, but, with all the respect, you didn't said anything new.
It's obvious that cms has to somehow find the file. It's obvious that id needs to be used. I am aware of that. I am also aware of implications that could have on existing files put outside the media.
I asked a question whether it's possible to have impact on that without url rewrite and the answer isn't that obvious. That's because umbraco has several undocumented features and hacks and that could be one of them.
Thanks for help anyway.
slawekg,
I've not done/tried this myself, but you could try to add a new property to your media item with alias = umbracoUrlAlias or alias = umbracoUrlName. I know it works for content items, so it might also work on media items (I wouldn't know why atm)
More info can be found on the wiki
Hope this helps.
Cheers,
/Dirk
Nope, that doesn't seem to work. Thanks for help anyway.
is working on a reply...