Post Field > Background Image bug

I’m trying to link div with background images to wordpress. I added Post Field - Smart action to a div with a background-image, set the Field Id to a unique value and Edit as Background image.
Now in wordpress, when I reload the page preview, I get the error:

Parse error : syntax error, unexpected token “?” in C:\xampp\htdocs\xxx\wp-content\themes\xxx\page-test.php on line 3

If I change the Post Field from Background image to Image or Content, it works fine. But the moment, I use Background image, get the above error.

HTML in Pinegrow:
<div style="height: 80vh;" cms-post-field="test" cms-post-field-type="background-image"></div>

Generated PHP:
<div style="height: 80vh;background-image:<?php echo 'url('<?php echo get_template_directory_uri(); ?>/.PG_Image::getUrl( get_post_meta( get_the_ID('), 'test', true ), 'large' ).')' ?>;"></div>

It works if I change the PHP code by removing the <?php echo get_template_directory_uri(); ?> part and removing the single quote inside get_the_ID() function call parantheses:

<div style="height: 80vh;background-image:<?php echo 'url('PG_Image::getUrl( get_post_meta( get_the_ID(), 'test', true ), 'large' ).')' ?>;"></div>

But of course, it gets overwritten with the incorrect code if I save the page again from Pinegrow

@Antzy this is now fixed.

Try the fix now on Pinegrow Live:

Thanks for such a quick fix! Will check the live version and update here.

Tested and it works correctly now.

1 Like