Copied to clipboard

Flag this post as spam?

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


  • Brock 2 posts 22 karma points
    Jul 29, 2015 @ 19:52
    Brock
    0

    Configuring Datatypes: File Upload*

    I am working in Umbraco 7. I am attempting to use the Datatype: File Upload in an existing template. I have created a custom data type and I have also applied the datatype to the Document Type . I am sure how to go about applying the Datatype to the template so that when an image is uploaded in the content section, it appears in the rendered version of the template when previewed or published.

    If anyone can provide assistance I would greatly appreciate your time and consideration.

    Thanks.

  • Mark Bowser 273 posts 860 karma points c-trib
    Jul 29, 2015 @ 20:13
    Mark Bowser
    0

    if you stick the upload property directly onto a document type instead of using a Media Picker, it will go something like this.

    @{
        var imageRelPath = Model.Content.GetPropertyValue<string>("uploadAlias");
    }
    
    <img src="@imageRelPath" alt="stuff" />
    

    Or maybe like this if you like using the dynamic stuff. Forgive me if this is off a bit. I prefer the more strongly typed IPublishedContent over the dynamics, so I'm way out of practice.

    <img src="@CurrentPage.uploadAlias" alt="stuff" />
    

    CurrentPage and Model.Content will both get you the current node. The first is as a dynamic. The second is as an IPublishedContent.

    The best way to go about figuring this sort of stuff out is to change the "Type" of the upload property on your document type into a Label. Doing so will not cause any data loss, but will change your property into a "read only" property editor that renders the raw data stored in the DB.

    Below is a screenshot of the Upload data stored in the database. Once you know what the data looks like, you can tell if you should just get it as a raw string or if it is something more complicated like some JSON.

    Backoffice Screenshot

Please Sign in or register to post replies

Write your reply to:

Draft