{"id":15566,"date":"2023-03-24T17:28:12","date_gmt":"2023-03-24T17:28:12","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=15566"},"modified":"2024-02-16T10:44:02","modified_gmt":"2024-02-16T10:44:02","slug":"responsive-iframe-wordpress","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=15566","title":{"rendered":"Responsive iframe (WordPress)"},"content":{"rendered":"<p><strong>Use the provided CSS classes from WordPress<\/strong><\/p>\n<p>Add the following call in the functions.php file of your current theme, if not already part of it.<\/p>\n<pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\r\n\/\/ Add support for responsive embed blocks.\r\nadd_theme_support( &#039;responsive-embeds&#039; );\r\n<\/pre>\n<p>(This adds the &#8216;wp-embed-responsive&#8217; CSS class to the &lt;body&gt; of your posts.)<\/p>\n<p>You can use the provided CSS classes with the following syntax in your posts.<\/p>\n<pre class=\"brush: xml; gutter: false; title: ; notranslate\" title=\"\">\r\n&lt;figure class=&quot;wp-has-aspect-ratio wp-embed-aspect-16-9&quot;&gt;\r\n\t&lt;div class=&quot;wp-block-embed__wrapper&quot;&gt;\r\n\t\t&lt;iframe ...&gt;&lt;\/iframe&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/figure&gt;\r\n<\/pre>\n<p>Link: <a href=\"https:\/\/github.com\/WordPress\/WordPress\/blob\/6.1.1\/wp-includes\/blocks\/embed\/style.css\">\/wp-includes\/blocks\/embed\/style.css<\/a> (on GitHub)<\/p>\n<hr>\n<p><strong>Alternative: Add your own CSS classes to the current theme<\/strong><\/p>\n<p>Add the following code at the end of the style.css file with an FTP client or the in-house editor.<\/p>\n<pre class=\"brush: css; gutter: false; title: ; notranslate\" title=\"\">\r\n\/*--------------------------------------------------------------\r\n# - Responsive iframe\r\n--------------------------------------------------------------*\/\r\n\r\n.res-con { \/* responsive-container *\/\r\n\tposition: relative;\r\n\twidth: 100%;\r\n\tpadding-top: 56.25%; \/* 16:9 Aspect Ratio *\/\r\n}\r\n\r\n.res-con.ar-16-9 {\r\n\tpadding-top: 56.25%; \/* 16:9 Aspect Ratio *\/\r\n}\r\n\r\n.res-con.ar-4-3 {\r\n\tpadding-top: 75%; \/* 4:3 Aspect Ratio *\/\r\n}\r\n\r\n.res-con iframe {\r\n\tposition: absolute;\r\n\ttop: 0;\r\n\tleft: 0;\r\n\twidth: 100%;\r\n\theight: 100%;\r\n}\r\n<\/pre>\n<p>(The default aspect ratio is 16:9, so you don&#8217;t have to add &#8216;ar-16-9&#8217;.)<\/p>\n<p>You can use the added CSS classes with the following syntax in your posts.<\/p>\n<pre class=\"brush: xml; gutter: false; title: ; notranslate\" title=\"\">\r\n&lt;div class=&quot;res-con ar-16-9&quot;&gt;\r\n  &lt;iframe ...&gt;&lt;\/iframe&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Use the provided CSS classes from WordPress Add the following call in the functions.php file of your current theme, if<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[55],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/15566"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15566"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/15566\/revisions"}],"predecessor-version":[{"id":16823,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/15566\/revisions\/16823"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15566"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}