Related to this old thread: Components attributes in embed html
For custom use-cases it would be great to be able to link component properties to lines within my custom embedded code (in the same way that it is currently done for Dynamic Embeds within CMS collection items)
Example:
I have a custom embed with the following code,
This is a mockup video player within an iFrame which gets around the lack of lazy-loading for embeded videos in webflow. This is essential for me as the client requires multiple embeded videos on one page but currently there is a drastic performance decrease on page load. (Source: Lazy load embedded YouTube videos | CSS-Tricks - CSS-Tricks)
<style>
.responsive-iframe-container {
position: relative;
width: 100%;
overflow: hidden;
padding-top: 56.25%; /* 16:9 Aspect Ratio */
}
.responsive-iframe {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
border: none;
}
</style>
<div class="responsive-iframe-container">
<iframe
class="responsive-iframe"
loading="lazy"
src="https://www.youtube.com/embed/Y8Wp3dafaMQ&autoplay=1"
srcdoc="<style>*{padding:0;margin:0;overflow:hidden}html,body{height:100%}img,span{position:absolute;width:100%;top:0;bottom:0;margin:auto}span{height:1.5em;text-align:center;font:48px/1.5 sans-serif;color:white;text-shadow:0 0 0.5em black}</style><a href=[https://www.youtube.com/embed/Y8Wp3dafaMQ?autoplay=1><img](https://www.youtube.com/embed/Y8Wp3dafaMQ?autoplay=1%3E%3Cimg) src=https://img.youtube.com/vi/Y8Wp3dafaMQ/hqdefault.jpg alt='Video The Dark Knight Rises: What Went Wrong? – Wisecrack Edition'><span>▶</span></a>"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
title="The Dark Knight Rises: What Went Wrong? – Wisecrack Edition"
></iframe>
</div>
Currently, I have to duplicate this embed and then manually edit the code to swap out the “src” / “srcdoc” / “title” properties, but it would be nice to leverage components to map these properties to the webflow editor.
I want to turn this embed into a component, and then create properties relating to:
- title
- srcdoc
- src
Then, as is done with a dynamic embed element, I want to pull these properties in within the embed itself, the result being something like:
<style>
.responsive-iframe-container {
position: relative;
width: 100%;
overflow: hidden;
padding-top: 56.25%; /* 16:9 Aspect Ratio */
}
.responsive-iframe {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
border: none;
}
</style>
<div class="responsive-iframe-container">
<iframe
class="responsive-iframe"
loading="lazy"
src=**{{property_src}}**
srcdoc=**{{property_srcdoc}}**
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
title=**{{property_title}}**
></iframe>
</div>
However, I don’t see this ability without having to wrap the whole component within a CMS collection, which is really overkill for this particular project as the section on the site is mostly static and won’t likely be updated.
I hope this can be an update to the component system, I imagine it’s not too difficult to implement with the UI that already exists for dynamic embeds.
In the meantime: Does anyone have any suggestions on how to get around this?
It is in fact possible to map the component properties to custom attributes, I have tried for several hours to get the values of the attributes of the ‘html embed’ element itself, from within the html embed. But so far, I have fallen short of success with this.
Any advice would be greatly appreciated!
Best,
Pat