Copied to clipboard

Flag this post as spam?

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


  • Jerker Stigsson 63 posts 122 karma points
    Nov 23, 2013 @ 19:35
    Jerker Stigsson
    0

    Not a bug, rather i how to question

    Would you like to show a code snippet, on how to use the GetMedia extension?

  • Bo Kingo Damgaard 157 posts 456 karma points
    Nov 23, 2013 @ 21:01
    Bo Kingo Damgaard
    0

    Hi Jerker

    Ofcourse. Here's an example where I pass a media picker item to the macro

    <xsl:param name="currentPage"/>
    <xsl:variable name="mediaItem" select="/macro/mediaItem"/>
    
    <xsl:template match="/">
    <xsl:if test="$mediaItem">
        <xsl:variable name="pdf" select="Flexit.PdfThumbnails:GetMedia($mediaItem/File/@id,0)"/>
        <h2><xsl:value-of select="$pdf/@nodeName"/></h2>
        <a href="{$pdf/umbracoFile}">Get full PDF here</a>
        <xsl:for-each select="$pdf//pdfThumbnails/file" >
            <img src="{.}"/>
        </xsl:for-each>
    
    </xsl:if>
    </xsl:template>
    
    /Bo
  • Jerker Stigsson 63 posts 122 karma points
    Nov 25, 2013 @ 10:04
    Jerker Stigsson
    0

    Thanks a lot!

  • Jerker Stigsson 63 posts 122 karma points
    Nov 25, 2013 @ 14:40
    Jerker Stigsson
    0

    But how do I use it with Razor syntax?

    I tried:

    var pdfThumb = Flexit.PdfThumbnails.Extension.GetMedia(item.Id, false);

    But there are not an pdfThumb.GetPropertyValue() extension available.

  • Bo Kingo Damgaard 157 posts 456 karma points
    Nov 26, 2013 @ 12:09
    Bo Kingo Damgaard
    0

    Hi Jerker

    I didn't include a Razor helper, because I didn't know how to.

    Bu I've just updated the package, and now there is a Razor helper - see package description for a Razor example

    /Bo

  • Jerker Stigsson 63 posts 122 karma points
    Nov 26, 2013 @ 14:55
    Jerker Stigsson
    0

    Super!!! Thanks!!! I'm sorry I have one more question. If I have some custom properties added to my File MediaType. How would I access them. My custom MediaType property is "documentMetaData".

    I tried:

    @pdf.Media.GetPropertyValue("documentMetaData").ToString()

    When I check to see if there was a property with that name with:

    pdf.Media.HasProperty("documentMetaData").ToString()

    I got false.

    I guess that your helper doesn't include custom properties? Or how would I go about it?

  • Bo Kingo Damgaard 157 posts 456 karma points
    Nov 26, 2013 @ 17:18
    Bo Kingo Damgaard
    0

    Hi Jerker

    That's weird. I think it's a bug in Umbraco. If I try to get "umbracoFile" it works as expected, but I dont get a custom property. I'll look into it.

    /Bo

  • Bo Kingo Damgaard 157 posts 456 karma points
    Nov 26, 2013 @ 18:13
    Bo Kingo Damgaard
    0

    Are you able to get you custom property using @Library.MediaById or any other function? I can't in 6.1.6

    /Bo

  • Jerker Stigsson 63 posts 122 karma points
    Nov 26, 2013 @ 20:26
    Jerker Stigsson
    0

    I use Umbraco.TypedMedia(). It works well in 6.1.5.

  • Bo Kingo Damgaard 157 posts 456 karma points
    Nov 26, 2013 @ 21:07
    Bo Kingo Damgaard
    0

    Hmm... are you using MVC or WebForms? I can't find the Umbraco.TypedMedia namespace

  • Jerker Stigsson 63 posts 122 karma points
    Nov 26, 2013 @ 21:59
    Jerker Stigsson
    0

    MVC

    In an Partiel View Macro I have this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Flexit.PdfThumbnails;
    
    @{
    var rootMedia = Umbraco.TypedMedia(2206).Descendants().Where(x => x.DocumentTypeAlias == "File").OrderBy(x => x.Name);
    
    foreach (var item in rootMedia)
    {
    var pdf = PDFHelper.GetMedia(item.Id);
    foreach (var thumb in pdf.PdfThumbs)
    {
    <a href="@pdf.Media.Url" target="_blank">@pdf.Media.Name</a>
    <img src="@thumb.fileName" style="max-width:30px;" />
    }
    }
    }
    
  • Bo Kingo Damgaard 157 posts 456 karma points
    Nov 27, 2013 @ 13:23
    Bo Kingo Damgaard
    0

    Apparently GetProperty doesn't work. You should use @pdf.Media.customProperty

    /Bo

  • Jerker Stigsson 63 posts 122 karma points
    Nov 27, 2013 @ 15:19
    Jerker Stigsson
    0

    That was a new one to me. Havn't seen that one before. Thanks!

  • Jerker Stigsson 63 posts 122 karma points
    Dec 02, 2013 @ 16:58
    Jerker Stigsson
    0

    O, totally missunderstod. Kind of funny. I thought there was a new extension method with that name - customProperty. But of course, it's the strongly typed property name.

Please Sign in or register to post replies

Write your reply to:

Draft