Get size of renderered image

For SEO reasons I enhanced the views/renderers/asset/image/default.cfm file and added the width and height attribute.

Works fine so far, but when using a derivative, I still get the size of the original image, but not the dimenstions of the rederered image. In the admin this leads to some curious effects, displaying icon really big.

How can I get the dimensions of the renderered image?

Best
Michi

Have you looked at AssetManagerService.getAssetDimensions()?

Will return the dimensions of the specified asset, and of a specific derivative of it if you pass in a derivative name…

That’s it, thank you.

Background: Form SEO perspective it is helpful to assign the width/height to an image.

I did the following:
Extending handlers/renderers/asset with the following function:

public string function default( event, rc, prc, args={} ){

  var dimensions = AssetManagerService.getAssetDimensions(args.id, args.derivative?:'', args.activeVersion?:"");
  args.renderedWidth = dimensions.width ?: args.width;
  args.renderedHeight = dimensions.height ?: args.height;

  return renderView( view="/renderers/asset/image/default", args=args );
}

In the corresponding view the attributes are added to the img-tag.

Note: I think this should be part of the preside core.

Thanks
Michi