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

Using ACF field name as parameter to @image directive - view not being recompiled when ACF field value is updated. #117

Closed
JakeJolt opened this issue Aug 22, 2023 · 2 comments · Fixed by #144

Comments

@JakeJolt
Copy link

Hi @Log1x,

Thanks so much for your work on this, I love the simplicity of of my markup using these directives. I have an issue I’m wondering if you can help with:

I’m using the @image directive inside a blade template for an ACF block (using mwdelaney/sage-acf-gutenberg-blocks). I’m passing an ACF field name as the first argument ie. @image( 'my_image_field', 'large', ... ). Strangely, when I update the value of this field in the block editor, for example swapping an image, the view isn’t being re-compiled and I continue to see the cached view (with the old field value) when I refresh the page. After running the WP CLI command wp acorn view:clear the view is updated and displays correctly. This issue does not occur if instead of passing the field name as the first argument, I pass the value itself ie. @image( get_field( 'my_image_field' ), 'large', ... ).

I don’t know much about how views are cached in Sage and I’m struggling to find much information on it, so apologies if this isn’t actually anything to do with your code, but thought perhaps you might be able to shed some light.

Thanks a lot,

@Log1x
Copy link
Owner

Log1x commented Aug 22, 2023

I'm assuming something weird is happening with https://github.com/Log1x/sage-directives/blob/master/src/Directives/WordPress.php#L433 – I probably need to move the get_field() call/conditions into the Blade echo its self.

I will try to mess with it sometime this week unless you want to try your hand at a PR.

@JakeJolt
Copy link
Author

Thanks for the pointer, looks like that solves it. I'll test and submit a PR.

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