-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Wordpress @image directive returns image ID instead of get_field function when using ACF #50
Comments
Are you passing it as a string? |
Of course - my code looks like: <div class="homepage-header-image">
@image('header.section.photo' , 'full', [])
</div> and rendered blade looks like <div class="homepage-header-image">
<?php echo wp_get_attachment_image(
22,
'full',
false,
[]
); ?>
</div> So if I change image in Wordpress this change does not make effect until I don't clear rendered views. I create own directive which is fair enough for this moment - code for it looks like duplicate of $expression = Util::parse($expression);
$image = Util::strip($expression->get(0));
if (
is_string($image) &&
!is_numeric($image) &&
Util::field($image)
) {
$fieldKey = $expression->get(0);
$expression = $expression->put(0, "get_field({$fieldKey})");
} If we implement this on Wordpress directive this can be violation of SRP because WordPress do not have to worry about ACF. What do you think? |
yes, unfortunately i have the same issue. workaround: |
Hello - was there ever a permanent solution to this issue? It appears to be similar to: https://discourse.roots.io/t/blade-directives-for-sage/14301/32 And I'm having the same issue, though the solution above from @kukac7 doesn't work for me, for some reason |
When I using
@image
directive with ACF key, Blade renders it aswp_get_attachment_image(<image id here>, ...)
instead ofwp_get_attachment_image(get_field('acf key here'), ...)
. It is problem because image ID by ACF is dynamic and after change it in dashboard, changes does not make effect until rendered views will not be deleted. It is persistent on application in production mode and very dynamic content.The text was updated successfully, but these errors were encountered: