Just like the umbracoFile, umbracoHeight etc. you can print out the umbracoBytes peoperty in the frontend using the GetMedia-extension. Is this what you want to do?
The $pdfFile needs to contain a media node id. So you probably need to wrap the value-of inside an if-statement checking whether the $pdfFile is empty or not.
This newsPDF-field - is this an upload data type? It sure looks like that, when you're not using the GetMedia extension. Unless you've created your own XML, and put the path to the pdf in an element called newsPDF.
Lee, I haven't seen an extension like that anywhere, so go for it! It would be very useful in situations like this one. Maybe an extension to grab the width and height from a path would also be great in situations where it's an image that's uploaded. +1!
Just added the "GetFileSize" extension to uComponents (here). We've already got extensions for "GetImageHeight" and "GetImageWidth" - check out the docs. There's also one for getting the <img> tag itself: "GetImageHtml".
Best way of displaying umbracoBytes for a pdf file
What is the best possible way of displaying file size of uploaded pdf using umbracoBytes?
//fuji
Hi Fuji
Could you ellaborate a bit more on your thoughts on this? Is it in visual terms on the frontend of a website or in the backend of Umbraco or?
/Jan
Hey Jan,
Its more on the frontend of the website. I would like to display the file size of uploaded pdf file that user will be able to download.
//fuji
Hi Fuji
Just like the umbracoFile, umbracoHeight etc. you can print out the umbracoBytes peoperty in the frontend using the GetMedia-extension. Is this what you want to do?
/Kim A
I have used the following to display 15 KB or 3 MB:
Hi Fuji..
Try to take a look at this: http://our.umbraco.org/wiki/reference/code-snippets/listfilesfrommediafolderxslt/find-media-file-sizes
Bjarne
Hi Kim,
I tried this earlier but instead I get an parsing error
Hmm...could you try shoing us your whole xslt?
The $pdfFile needs to contain a media node id. So you probably need to wrap the value-of inside an if-statement checking whether the $pdfFile is empty or not.
/Kim A
Hi Kim,
Here is how am doing it
Its giving me the right pdf file but would also like to show the file size
This newsPDF-field - is this an upload data type? It sure looks like that, when you're not using the GetMedia extension. Unless you've created your own XML, and put the path to the pdf in an element called newsPDF.
/Kim A
Yes its an upload field where the client will decide if he wants to include a pdf file or not.
//fuji
Any know if an XsltExtension is already out there for getting the filesize from a filepath?
If not, then I'll add one to uComponents (in the IO extension), for the next release! :-D
Cheers, Lee.
Hi Fuji,
Out of couriosity, what does this give you: <xsl:copy-of select="$pdfFile" /> ? :-)
Lee, I haven't seen an extension like that anywhere, so go for it! It would be very useful in situations like this one. Maybe an extension to grab the width and height from a path would also be great in situations where it's an image that's uploaded. +1!
/Kim A
Hey Kim,
Just added the "GetFileSize" extension to uComponents (here). We've already got extensions for "GetImageHeight" and "GetImageWidth" - check out the docs. There's also one for getting the <img> tag itself: "GetImageHtml".
Cheers, Lee.
Ooh didn't see them Lee. My bad. But great work on the GetFileSize-extension! :)
Will check it out soon.
/Kim A
is working on a reply...