Copied to clipboard

Flag this post as spam?

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


  • Kyle Goulding 30 posts 192 karma points
    Jul 15, 2016 @ 08:48
    Kyle Goulding
    0

    Umbraco - Document attachments - File Upload or Content Picker

    Hi,

    I am looking for the best way to add attachments - is it best for the editor to upload the document to the Media gallery and then use a Media Picker to link to the document or a file upload?

    I thought using the Media Picker would be better then the document is stored on the site and not just against the item like the File Upload.

    But I am having issues displaying the link to the document when using the Media Picker. It works fine for images using -

    @(node.GetPropertyValue("ImageAlias")) - in the

    But when trying to include the document in an <a href=""></a> it is just displaying the ID

    @(node.GetPropertyValue("DocumentLinkAlias") 
    

    and if i use

    @Umbraco.NiceUrl(node.GetPropertyValue<int>("DocumentLinkAlias"))
    

    it displays a #.

    Can someone help me with this?

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jul 18, 2016 @ 21:21
    Alex Skrypnyk
    0

    Hi Kyle,

    If you are using file more than one time - use media library.

    If file is only one timer - you can use file upload, but I would prefer media library too.

    For getting url of media item use:

    var media = Umbraco.TypedMedia(1234);
    var fileUrl = media.Url;
    

    Thanks,

    Alex

  • Kyle Goulding 30 posts 192 karma points
    Jul 19, 2016 @ 07:55
    Kyle Goulding
    0

    Hi Alex,

    Thanks for providing this. I wanted to use the media folder for attach documents so that I had more control over the documents so we could have it stored on the server still even if it wasn't in use, as opposed to just attached to the record. I think editors would have found it a bit more worrying if they deleted it etc.

    I wanted the URLs to by dynamic as I was including the code in a partial view. I have changed it now to use a Content Picker for pages within the site and a textstring so media items i.e. documents, to just include the URL, and this way I can also include external links as well.

    Would be great to see a link picker data type which gave editors the functionality to pick either a page from the site, or browse to a media item or specify a URL, along with specifying the target value.

    Thanks for your response.

Please Sign in or register to post replies

Write your reply to:

Draft