I’m trying to rewrite the following php code with an element to a element:
Old:
if($attachments) $latest_topic['media'] = '<img class="topic-media-thumbnail odp-mr-2" src="' . wp_get_attachment_image_src($attachments[0]->ID, 'thumbnail')[0] . '" />';
New:
if($attachments) $latest_topic['media'] = '<div style="
background-image: url('<php wp_get_attachment_image_src($attachments[0]->ID ?>');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
aspect-ratio: 1/1;">
</div>';
The problem is that the php tag is being shown as an undefined constant in the following code:
background-image: url(‘<php wp_get_attachment_image_src($attachments[0]->ID ?>’);
Trying to render the old style images into the new div.
What am I doing wrong?