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

When adding an image in a matrix block - preparse only works on second save #29

Open
terryupton opened this issue Mar 27, 2017 · 0 comments

Comments

@terryupton
Copy link

So I am using a Matrix block and Imager with Preparse. I have a prepares field part of the image block within the Matrix field and the following code;

{% set image = matrixblock.image[0] ?? null %}
{% set alt = (matrixblock.caption ?: image.title) %}

{% set imageRatioWidth = 16 %}
{% set imageRatioHeight = 11 %}
{% set mode = 'crop' %}
{% set imageSizes = [
	{ width: 1600 },
	{ width: 1400 },
	{ width: 1200 },
	{ width: 800 },
	{ width: 600 },
	{ width: 450},
	{ width: 300}
] %}

{# Set Srcset Transform #}
	{% set transformedImages = craft.imager.transformImage(image, imageSizes, { mode: mode, ratio: imageRatioWidth/imageRatioHeight, position: ('50' ?? image.focusPctX) ~ '% ' ~ ('50' ?? image.focusPctY) ~ '%', jpegQuality: 80 }) %}

	{% set largestImage = transformedImages[0] %}

However, the preparse field only seems to run/work when the article is saved on the second instance. If I add a new image block, upload the image to the assets manager and choose the uploading image. Then save the post nothing happens. if I save the post a second time, the preparse works.

Is this a bug or is my setup slightly wrong?

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

No branches or pull requests

1 participant