Fórum

How to get document library image dimensions in velocity / scale dlimage?

Mikko Torri, modificado 9 Anos atrás.

How to get document library image dimensions in velocity / scale dlimage?

Junior Member Postagens: 25 Data de Entrada: 22/04/14 Postagens Recentes
Hi

I'm having trouble getting the image dimensions of a file in Document Library in a velocity template.

It's a display template for a structure which has the "document-library" type item in it. (<dynamic-element dataType="document-library" fieldNamespace="ddm" indexType="keyword" name="document" readOnly="false" repeatable="true" required="false" showLabel="true" type="ddm-documentlibrary" width="">)

I need to calculate the correct height and width of the image to scale it down so it is displayed correctly in the container it is in. (if it's smaller it can stay that way)

I see the data is in the ddmcontent object, but I can't seem to get the relation in between DLFileEntry and DDMContent right in the vm-template.
It's down to the linking of DLFileEntry and DLFileEntryMetadata as there's no method in DLFileEntryMetadataLocalService to get by fileEntryId.

I don't suppose there's a utility to scale the image down.
(and no, setting the image dimensions to the container is not an option since it will break the aspect ratio)

Thanks

M
thumbnail
Dave Weitzel, modificado 9 Anos atrás.

RE: How to get document library image dimensions in velocity / scale dlimag

Regular Member Postagens: 208 Data de Entrada: 18/11/09 Postagens Recentes
Why try to set dimensions? in today's responsive world images with dimensions set are horrendous.

Just set the container the image is to be in to be the relevant percentage width of of its container and then set img { max-width:100%;}

if your image is too large it will be scaled to the container width (retaining aspect) and if smaller it should stay its original size.
[not to be confused with width:100% which would blow it up.]
Mikko Torri, modificado 9 Anos atrás.

RE: How to get document library image dimensions in velocity / scale dlimag

Junior Member Postagens: 25 Data de Entrada: 22/04/14 Postagens Recentes
Thanks Dave, I'll give it a try!

Mikko
Mikko Torri, modificado 9 Anos atrás.

RE: How to get document library image dimensions in velocity / scale dlimag

Junior Member Postagens: 25 Data de Entrada: 22/04/14 Postagens Recentes
Doesn't work, or I didn't get it right. It's a background image for a div, and it seems it doesn't work for that. So I guess I've got some more css magic to learn and make it an image in the div and get some <span>text</span> on top of it.

Mikko