How to set a correct $content_width when there are two content widths on one page?

Currently I have 1860px wide image as featured image which shows on top of a post page, and 800px as post content width, and when I

Set $content_width = 800

The featured image shows as 800px wide only

Set $content_width = 1860

Featured image shows well, but embedded youtube video shows as 1860 x 1077, I tried to set max-width:100% on iframe, it fixed the width, but height still 1077, a height:auto has no effect.

Any suggestion?

Topic content-width theme-development Wordpress

Category Web


You can set iframe tag with width:100%
Let say you have the following structure

<div class='video'>
     iframe tag here    
</div>
<style>
.video iframe {
    width: 100%; // this will automatically adjust the height
}
</style>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.