Discussion:
[TYPO3-english] Original width and height of image in fluid
Vikram Mandal
2017-09-04 15:41:23 UTC
Permalink
Hi,

How can I get the original width and height of an image in fluid template?
--
Vikram
=============================
http://T3IN.COM
FiveE Technologies.
=============================
Jigal van Hemert
2017-09-05 07:25:59 UTC
Permalink
Hi,
Post by Vikram Mandal
How can I get the original width and height of an image in fluid template?
If 'image' is the file reference object it would be
{image.originalFile.width}
--
Jigal van Hemert
TYPO3 CMS Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Vikram Mandal
2017-09-06 05:24:37 UTC
Permalink
Post by Jigal van Hemert
If 'image' is the file reference object it would be
{image.originalFile.width}
I am trying to get the width and height of an image in news. So I tried :

{newsItem.firstFalImagePreview.originalFile.width}

{newsItem.firstFalImagePreview.width}

But none seems to work.

newsItem.firstFalImagePreview returns
\TYPO3\CMS\Extbase\Domain\Model\FileReference
--
Vikram
=============================
http://T3IN.COM
FiveE Technologies.
=============================
Vikram Mandal
2017-09-08 08:19:01 UTC
Permalink
Post by Jigal van Hemert
If 'image' is the file reference object it would be
{image.originalFile.width}
width and height are protected vars. To access them we need to use the
getProperty() method.

Now the problem is how do call a method inside fluid template. One
approach is building a viewhelper. The Vhs extension provides one.

{object -> v:call(method: 'toArray')}
--
Vikram
=============================
http://T3IN.COM
FiveE Technologies.
=============================
Jigal van Hemert
2017-09-12 20:51:02 UTC
Permalink
Post by Vikram Mandal
Post by Jigal van Hemert
If 'image' is the file reference object it would be
{image.originalFile.width}
width and height are protected vars. To access them we need to use the
getProperty() method.
To access properties Fluid will call getXxx methods. In some objects
there are getXxxx functions which calculate a property that is not
directly present in the object. If you generate debug output from that
object you won't see the property but you can use it in Fluid.
--
Jigal van Hemert
TYPO3 CMS Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Jigal van Hemert
2017-09-12 20:34:29 UTC
Permalink
Post by Vikram Mandal
Post by Jigal van Hemert
If 'image' is the file reference object it would be
{image.originalFile.width}
{newsItem.firstFalImagePreview.originalFile.width}
{newsItem.firstFalImagePreview.width}
But none seems to work.
newsItem.firstFalImagePreview returns
\TYPO3\CMS\Extbase\Domain\Model\FileReference
Ah, the news firstFalImagePreview :-)

Looking at the code it must be
{newsItem.firstFalImagePreview.originalResource.originalFile.width}
--
Jigal van Hemert
TYPO3 CMS Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Loading...