Replies: 2 comments
-
Great summary. Converted it to a discussion to keep it as a resource for other users. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Does this still appy for Craft 5? I'm struggling to get auto generation of matrix block images (not nested) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is not so much a bug report, but more a short note in case somebody stumbles over the same issue. According to the docs (https://imager-x.spacecat.ninja/usage/generate.html#setting-it-up) and this comment (#75 (comment)) we know that Imager does support both Matrix and SuperTable. Here's an example starting with a plain entry:
This will transform a field
heroImage
(which should be an image) in a section calledarticle
with the transformationtransform16x9
. IfheroImage
would be a field inside a Matrix Block, we would use something like this:In this example
blocks
is the Matrix field,heroImage
the type (block type) inside the Matrix, andimage
the actual assets field.As SuperTables don't have block types, we would have to use this syntax:
As mentioned in #75 (comment), Imager doesn't support nested Matrix inside SuperTable or the other way round, however we can use the same element query like this:
Unfortunately this gets a little bit uglier, but not complicated. Craft requires the
fieldId
of the block (see craftcms/cms#1789 (comment)) which can be found in/admin/settings/fields
. That will limit your query to this specific Matrix or SuperTable field. Next you can specify all block types you want to transform intype
. In fields you can specify the individual field name. The trick here is that you can use the same syntax as above (ie.<matrixFieldHandle>:<matrixTypeHandle>.<fieldHandle>
or<SuperTableFieldHandle>:*.<fieldHandle>
. Also, these fields will match all fields in the specified types, ie. ifquote
andheroImage
both have a fieldimage
you'll catch both with specifying it just once.This is actually true for all rules you specify: If any rule matches the transformation will be executed. To have two transformations executed for the same field (or a combination of block types and fields) you can either:
or
That allows you to get creative in how you combine different blocks and fields with their respective transformations.
Hope this helps!
Beta Was this translation helpful? Give feedback.
All reactions