Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target an image handle for auto generation only inside a matrix #39

Open
1 of 3 tasks
alexroper opened this issue Jul 23, 2020 · 5 comments
Open
1 of 3 tasks

Target an image handle for auto generation only inside a matrix #39

alexroper opened this issue Jul 23, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@alexroper
Copy link

I'm submitting a...

  • bug report
  • feature request
  • general question

Description

Is it possible to target an image handle inside a specific matrix field for auto transform generation? Can I do this without targeting all fields with the same handles?

Say I have a matrix field named content with a block type named carousel and a field inside that with the handle of image.

This seems to work:

'fields' => [
    'image' => ['myTransform'],
],

But this doesn't:

'fields' => [
    'content:carousel.image' => ['myTransform'],
],

The format that uses <matrixFieldHandle>:<matrixTypeHandle>.<fieldHandle> only seems to work with elements.

'elements' => [
    [
        'elementType' =>  \craft\elements\Entry::class,
        'criteria' => [
            'section' => ['news'],
        ],
        'fields' => ['content:carousel.image'],
        'transforms' => ['myTransform']
    ],
],

Is this working correctly or am I doing something wrong?

Additional info

  • Imager version & edition: Pro v3.0.9
  • Imager transformer: imagemagick
  • Craft version: 3.4.18
  • PHP version: 7.3.8
  • Image driver & version: Imagick 3.4.3 (ImageMagick 6.9.6-2)
  • Database driver & version: MySQL 5.7.26
  • Plugins & versions (if relevant):
@aelvan
Copy link
Contributor

aelvan commented Jul 27, 2020

No, you're right, the matrix field handle syntax only works inside the elements functionality. Supporting it in the general fields functionality was a bit tricky, so I dropped it initially. But I'll leave this open and revisit it down the line.

FWIW, if you drop the criteria in an elements definition, it'll do the same thing. But you'll have to define it for each element type of course.

@aelvan aelvan added the enhancement New feature or request label Jul 27, 2020
@alexroper
Copy link
Author

Thanks. I thought that's how it worked but just wanted to make sure I wasn't missing something.

I realized this wouldn't be too painful if I just combine several sections in the element criteria. Didn't occur to me I could do that at first.

return [
    'elements' => [
        [
            'elementType' => \craft\elements\Entry::class,
            'criteria' => [
                'section' => ['news', 'about', 'blog', 'contact'],
            ],
            'fields' => ['pageContent:image.image'],
            'transforms' => ['imageBlock']
        ],
    ]
];

@daniellelecomte
Copy link

Is it possible to target an image inside of a super-table field in the same way that you can for a matrix field?
<matrixFieldHandle>:<matrixTypeHandle>.<fieldHandle>

@alexroper
Copy link
Author

alexroper commented Nov 20, 2020

@daniellelecomte I don't think so. My experiments with targeting image transforms inside a Super Table field haven't worked at all. But maybe I'm doing something wrong. ¯\_(ツ)_/¯

@aelvan
Copy link
Contributor

aelvan commented Nov 20, 2020

@daniellelecomte It's not at the moment, but shouldn't be too difficult to add. File a separate FR if you want me to look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants