Get Umbraco thumbnail image file size - umbracoBytes XSLT
I'm trying get the file size of the thumbnail jpg generated by ImageGen for an image gallery download section.
I've done it before in Umbraco 4.2 but I'm trying to update my XSLT and simplify it for Umbraco 4.9
Version 4.2 method:
<xsl:value-ofselect="emint:GetFileSize(((memberGroupFunctions:GetFileSize(concat(substring-before($mediaNode/data [@alias='umbracoFile'],'.'), '_thumb_1200.jpg')) div 1024) div 1024))"/>
What I'm trying to do for Version 4.9:
<xsl:value-ofselect="emint:GetFileSize(((memberGroupFunctions:GetFileSize(concat(substring-before(umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoFile,'.'), '_thumb_1200.jpg')) div 1024) div 1024))"/>
I can't understand why it's not working. The original image is uploaded to the Media seciton, it's cut to various sizes, including 1200 and 2400. The original image is then selected in the Content section using the Media Picker datatype. I then display it and the "thumb" versions on the page as downloadable links. The link includes the images width, height and file size. I just can't get the file size working on the "thumb" images! The width and height display. But the GetFileSize for the "thumb" images causes an "Error parsing XSLT file" error.
<ul> <li> <ahref="{concat(substring-before(umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoFile,'.'), '_thumb_1200.jpg')}"title="Medium"> Medium - <xsl:value-ofselect="emint:GetThumbailFileDimensionWidth(1200, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoHeight div 1, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoWidth div 1)"/> x <xsl:value-ofselect="emint:GetThumbailFileDimensionHeight(1200, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoHeight div 1, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoWidth div 1)"/> px <xsl:value-ofselect="emint:GetFileSize(((memberGroupFunctions:GetFileSize(concat(substring-before(umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoFile,'.'), '_thumb_1200.jpg')) div 1024) div 1024))"/> </a>
</li> <li> <ahref="{concat(substring-before(umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoFile,'.'), '_thumb_2400.jpg')}"title="Large"> Large - <xsl:value-ofselect="emint:GetThumbailFileDimensionWidth(2400, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoHeight div 1, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoWidth div 1)"/> x <xsl:value-ofselect="emint:GetThumbailFileDimensionHeight(2400, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoHeight div 1, umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoWidth div 1)"/> px <xsl:value-ofselect="emint:GetFileSize((umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoBytes div 1024) div 1024)"/> </a> </li> <li> <ahref="{umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoFile}"title="Original File"> Original File - <xsl:value-ofselect="umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoWidth"/> x <xsl:value-ofselect="umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoHeight"/> px - <xsl:value-ofselect="emint:GetFileSize((umbraco.library:GetMedia($currentPage/imageGalleryPhoto, 'false')/umbracoBytes div 1024) div 1024)"/> </a> </li> </ul>
Example of how the download list should display:
Medium - 1200 x 898 px - 225 KB
Large - 2400 x 1797 px - 777 KB
Original File - 6658 x 4984 px - 10.20 MB
This is the C# script I use for the width, height and file size conversions:
Get Umbraco thumbnail image file size - umbracoBytes XSLT
I'm trying get the file size of the thumbnail jpg generated by ImageGen for an image gallery download section.
I've done it before in Umbraco 4.2 but I'm trying to update my XSLT and simplify it for Umbraco 4.9
Version 4.2 method:
What I'm trying to do for Version 4.9:
I can't understand why it's not working. The original image is uploaded to the Media seciton, it's cut to various sizes, including 1200 and 2400. The original image is then selected in the Content section using the Media Picker datatype. I then display it and the "thumb" versions on the page as downloadable links. The link includes the images width, height and file size. I just can't get the file size working on the "thumb" images! The width and height display. But the GetFileSize for the "thumb" images causes an "Error parsing XSLT file" error.
Example of how the download list should display:
This is the C# script I use for the width, height and file size conversions:
Can anyone help?
Cheers, JV
is working on a reply...