How to replace the video id in a Vimeo url with a custom field?

Hi all,

Given this code that’s provided by Vimeo to embed their videos:

<iframe src="https://player.vimeo.com/video/282249835?title=0&byline=0&portrait=0" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

I have a custom field in Wordpress for the video id, and I’d like to replace the id in the code above (i.e. 282249835) with this value. Is that possible using smart actions?

I managed to find a way to do it using the Function smart action and echo’ing out the html and concatenating the id, but is this the best or only way?

Thanks

For a situation like that with a query string, I would actually manually insert that and not use the smart actions. That way, it’s inserting the field data dynamically exactly the way you intend it to be.

I love the PHP inserts and smart actions, but oftentimes they can get in the way with more complex insertions like this. When in doubt, manually code it into the template, there’s nothing wrong with that and it won’t break the PG HTML master template in the least. It’s also a cleaner export.

Thanks for the reply - could you elaborate on what you mean by manually insert?

This is what I have at the moment:

<div cms-function="code" cms-function-type="element" cms-function-code="$videoId = get_field('vimeo_video');     echo '<iframe src=&quot;https://player.vimeo.com/video/' . $videoId . '?title=0&byline=0&portrait=0&quot; style=&quot;position:absolute;top:0;left:0;width:100%;height:100%;&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; fullscreen&quot; allowfullscreen></iframe>'"></div>

This is using PGs Function smart action. Is there a better way to do it?

Thanks,
Chris