0

I have set up a theme with a width of 964 px, so that images in the post should be shown as 964 px, when set to 100% (or 964 px). I mean the complete width of the page/wrapper.

Unfortunately, this does not work, but I can not find the culprit.

Link: http://bit.do/c8q8u

Code, I used:

html:
<img src=".../x.jpg" alt="" width="964px" class="alignnone size-full wp-image-150" />


css:
#posts {width: 964px !important;}
.post .post-excerpt img {max-width: 100% or 964px;}

Thank you, guys.

1

in your class : .post .post-excerpt img add width instead of max-width

.post .post-excerpt img {
    width: 100%;
}

This seems culprit :

enter image description here

6
  • This solves the problem, thanks, but it sets all pictures to full width, when not stated with other sizes. I would rather like to know, why the max-width is somehow 634 px, when I have set it to be 964 px. Max-width should be 964 instead and fully okay to use, I think.
    – vega
    Feb 1 '17 at 14:15
  • Because you don't have the width element set, it uses the width of the image, which is 634px, so you either need to increase the size of the image or add the width element above. If you only want it on that page then add the following: .page-id-6 .post .post-excerpt img { width: 100%; } Feb 1 '17 at 14:21
  • add a class in img if you are adding image manually & apply css to it, if not then do as @gareth says Feb 1 '17 at 14:23
  • What?! No, the image size is way bigger. First, I tried it with a 3000 px image, then I used a perfect 964 px size. The size of the file is NOT 634 px, definitively. I even uploaded it twice, just to be sure. Also, I have set in html the correct size, see above quote. So, still with a 634 px size the image would be forced to be shown as 964 px. The image file is not wrong, that is safe to say.
    – vega
    Feb 1 '17 at 14:28
  • The limitation to 634 px lies somewhere else ... and I really would like to find that without having to use fixed sizes on all other images. You can even see in a debugger that the original size of the image is those 964 px, but it gets crunched to 634 px in any browser.
    – vega
    Feb 1 '17 at 14:32
0

I found the problem. The content width was forced in functions.php:

...

if ( ! isset( $content_width ) ) $content_width = 634;

add_theme_support( 'automatic-feed-links' );

...

I changed the value to 964 and it works like it should. :)

2
  • and i think now you dont need to force widths with css, right? Feb 1 '17 at 15:50
  • Yeah, more or less. I stayed on the max-width thing with 100% and that worked like it should. Small graphics stay small, bigger get reduced to the max size, as they should.
    – vega
    Feb 1 '17 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.