Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Nov 24, 2017 @ 13:43
    Claushingebjerg
    0

    Media url or preview backend

    Is there a way to get the filename or even better an image preview using the "Name template"?

    I have a simple doctype, that only contains a media picker. When using the media picker in the "Name template" i get something like "umb://media/29bf4d2ca5384c8f99f0411fde640d17".

    It would be cool with a small preview or simply the file name "image.jpg"

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 24, 2017 @ 14:40
    Lee Kelleher
    101

    Hi Claus,

    You can create a custom preview for the row.

    Our documentation for it is currently lacking, but Nik posted a couple of steps on another forum thread...

    https://our.umbraco.org/projects/backoffice-extensions/stacked-content/stacked-content-feedback/89104-documentation#comment-281660

    Hope this helps?

    Cheers,
    - Lee

  • Claushingebjerg 939 posts 2574 karma points
    Nov 24, 2017 @ 14:43
    Claushingebjerg
    0

    Stupid me. I was fully aware of the custom preview... I just didn't think. I guess its friday.

    Thanks, H5YR. Awesome Package.

  • Claushingebjerg 939 posts 2574 karma points
    Nov 24, 2017 @ 14:47
    Claushingebjerg
    1

    And it works like a charm... Of course :)

  • Sebastian Dammark 583 posts 1407 karma points
    Jan 06, 2018 @ 15:44
    Sebastian Dammark
    0

    Does any of you have a simple example of a custom preview ?

    I've tried @Model.Content but I get an error looking like this:

    'Umbraco.Core.Models.PublishedContent.PublishedContentWrapped.Content' is inaccessible due to its protection level
    

    And this is my code:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ImageSection>
    
    @{bool isFrontEnd = UmbracoContext.Current.IsFrontEndUmbracoRequest;
    var element = Model.Content;
    
    <div>
        <div>@element.Name</div>
    </div>}
    
  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Jan 07, 2018 @ 13:05
    Søren Kottal
    0

    Hi Sebastian

    You don't have to write Model.Content, when you use UmbracoViewPage. You can just write Model, like Model.Name, Model.Url etc.

  • Claushingebjerg 939 posts 2574 karma points
    Jan 06, 2018 @ 15:51
    Claushingebjerg
    1

    I do it like this

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    
    @{
        var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("scrollBillede");     
        string mediaString = @Model.Content.GetPropertyValue("baggrundsbillede").ToString(); 
        int mediaID = mediaString.AsInt();      
        var mediaItem = Umbraco.TypedMedia(@mediaID); 
    }
    
    
    <div style="width:100%; text-align:center"><img style="width:100%;" src="@Url.GetCropUrl(mediaItem, height:200, width:700)"/></div>
    

    Remember to:

    1. in Views/Partials create a folder called "stack"
    2. Create cshtml views who's name match the alias of the document type you are previewing - e.g. "programmeEntry"
    3. Ensure these views inherit from UmbracoViewPage
  • Sebastian Dammark 583 posts 1407 karma points
    Jan 07, 2018 @ 01:22
    Sebastian Dammark
    0

    Oh, yes. That works. Thank you

  • Sebastian Dammark 583 posts 1407 karma points
    Jan 07, 2018 @ 01:25
    Sebastian Dammark
    0

    Do you know if it's possible to, somehow, get a CSS file loaded so you don't have to do all that inline styling ?

  • Sebastian Dammark 583 posts 1407 karma points
    Jan 07, 2018 @ 01:44
    Sebastian Dammark
    2

    I figured this out on my own.

    Just create a manifest in ~/App_Plugins/WhateverYouWant/

    Make it look like this:

    {css: [
        '~/App_Plugins/WhateverYouWant/styles.css'
    ]}
    

    And add the styles.css to the same folder

Please Sign in or register to post replies

Write your reply to:

Draft