Copied to clipboard

Flag this post as spam?

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


  • Seweb_Francesca 16 posts 86 karma points
    Nov 14, 2016 @ 12:14
    Seweb_Francesca
    0

    use Media

    In Media how I can use File name instead of id?

    example in Content:

    i need to use only filename and foldername how i can resolve?

  • Marcio Goularte 389 posts 1362 karma points
    Nov 14, 2016 @ 12:32
    Marcio Goularte
    0

    Hi,

    Media has a property called umbracoFile.

    Razor Typed

     var media = Umbraco.TypedMedia(1234); 
    <img src="@media.GetPropertyValue("umbracoFile")" alt="@media.GetPropertyValue("Name")"/>
    

    Razor Dynamic

    var media = Umbraco.Media(1234); @media.Name

    https://umbraco.com/follow-us/blog-archive/2011/2/24/umbraco-47-razor-feature-walkthrough-part-2/

  • Seweb_Francesca 16 posts 86 karma points
    Nov 14, 2016 @ 13:17
    Seweb_Francesca
    0

    thank Now i have to use a path like this: /media/folder/filename.pdf

    in a javascript file

    how i can do it, using filename instead of id? In javascript i can't use @Umbraco syntax

  • Marcio Goularte 389 posts 1362 karma points
    Nov 14, 2016 @ 14:24
    Marcio Goularte
    0

    If javascript is inline in view, you can use the media variable in javascript:

    @
    {
       var media = Umbraco.TypedMedia(1234);
    }
    
    <script type="text/javascript">
    
        var urlfile = '@media.GetPropertyValue("umbracoFile")';
    
    </script>
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies