Plugin Events

Hello. I wanted to know the orientation of an image on upload, in MoreGallery, modx3.
For this I try to do a plugin with event MoreGallery_OnImageCreate. But it’s not going well… :slight_smile:
How to use the events and options like $object? Is there some where a little explanation?

Thanks for your help

Is there a specific reason you want to do that on upload? MoreGallery already extracts EXIF and rotation data on upload, uses it to rotate the source image if needed, and makes EXIF data available as placeholders for use later.

If I know it on upload, I can register it in a tv, and use it later for filtering. I want to display only the vertical images.
I don’t think that I can have a &where filter to only display the vertical or the horizontal images, no?

Haven’t tried, but maybe like this?

    "other": "simple condition", // if you have any
  "`width` > `height`"

Super! with &where=[“width > height”]``, it give me only horizontal images. It’s this logical I want.
But now why is it without {} and must be between []?

Thanks a lot!

PS: I still interest with the plugin events howto! :slight_smile:

That has to do with how xPDO handles the condition.

A key => value pair like [{"width:>":"height"}] will escape the value. So it would not compare the width to the actual height, but to the literal string “height”.

Passing as just a string like ["`width` > `height`"] doesn’t apply that, so it will compare the width and height columns.

1 Like

The $object you get access to in the plugin is the mgImage object, so you can use that to get to the file contents and such, as well as any other data stored on the object (like the exif data).