43homes
asked on
Featured Image 100% Width
I am trying to size the featured image, or post thumbnail, to automatically stretch the image to 100% width of the div, regardless of the size of browser you are viewing the site in. I am able to get this to work with divs that have a background image using the style attribute cover. But since the featured image is not in the background this solution doesn't seem to work.
I have tried setting img for the div to 100% with no avail.
To reference the page in question, you can view http://mj2marketing.com/borror/2015/01/from-high-street-to-wall-street/. CSS is included below. I have not included size settings in functions.php.
I have tried setting img for the div to 100% with no avail.
To reference the page in question, you can view http://mj2marketing.com/borror/2015/01/from-high-street-to-wall-street/. CSS is included below. I have not included size settings in functions.php.
#blog .featuredimg {
width: 100%;
height: 200px;
padding-top: 300px;
text-align: center;
border-bottom: 5px solid #b51218;
}
#blog .featuredimg img {
width: 100%!important;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
ASKER
I thought about. I added it as a featured image using the dialogue in wordpress. I can see when trying to edit the image there that it has the dimensions set as 600 x 300 (which is the image's original size). I don't appear to have an option to not apply a size in the edit image options. Any ideas on how to remove this html attribute that appears to be set by the featured image?
If the dialogue tool is not allowing you to do a simple thing like write a line of code then don't use it and write the code yourself. If you are limited to working through and abstracted level and can't code then you need to be prepared to live with very limited capabilities, or hire a professional to do the work for you.
If you look at the backend of the dialogue you should see what variables are being set for the width/height, and then you just need to eliminate the bit of code that generates the image portion of the page.
Or you can wait and see if Jason or one of the other WP internals guys come along. I don't do WP internals, and most of the time I would rather it did not exist.
Cd&
If you look at the backend of the dialogue you should see what variables are being set for the width/height, and then you just need to eliminate the bit of code that generates the image portion of the page.
Or you can wait and see if Jason or one of the other WP internals guys come along. I don't do WP internals, and most of the time I would rather it did not exist.
Cd&
ASKER
I came for help, not lectures. I rather people who are snarky and have this attitude just chose not to respond. Best to you.
You can try to add this to your child theme's style.css:
#featuredimg img {
max-width: 100%;
height: auto;
width: 100%;
}
#featuredimg img {
max-width: 100%;
height: auto;
width: 100%;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Snarky??? Oh I get it anyone who expects someone using a tool to actually be familiar with how it works is snarky.
To be a plumber you need a license and testing to demonstrate you actually know how to do the job; maybe we need the same for those who think they are web developers because they can get a WP page to render without hanging the browser.
Cd&
To be a plumber you need a license and testing to demonstrate you actually know how to do the job; maybe we need the same for those who think they are web developers because they can get a WP page to render without hanging the browser.
Cd&
You may also want to install the plugin called "Regenerate Thumbnails". Once you use an image as featured it's sort of cached at a specific size until you regenerate.
You can add a few lines of code and have your own featured image sizes:
In the functions.php you can add this code:
This is an example of a new attachment image size I've created for my theme. The values are: name, height, width, and true/false for hard crop.
Once you've added this to your functions.php, simply add the name of new image size inside the parentheses your featured image code like this:
You can add a few lines of code and have your own featured image sizes:
In the functions.php you can add this code:
add_image_size('blog-archive',225,225, true);
This is an example of a new attachment image size I've created for my theme. The values are: name, height, width, and true/false for hard crop.
Once you've added this to your functions.php, simply add the name of new image size inside the parentheses your featured image code like this:
<?php the_post_thumbnail('blog-archive'); ?>
ASKER
I've requested that this question be deleted for the following reason:
No answers were sufficient.
No answers were sufficient.
There were plenty of sufficient answers here. I believe that our answers were not able to be implemented do to the limited knowledge of the poster regarding WordPress development.
I agree with laugh; if the user is not skilled enough to implement simple solutions, they need to either upgrade their skills or hire a professional to do the work for them. The Experts did not fail to respond with appropriate solutions and should not be penalized because the skills required to implement are outside the range of the user.
Cd&
Cd&
Cd&