Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Problem to set height/border-radius for picture tag

  • Hello,

    I have a problem when I want to set a height for the image on a content template : in frontend, only the first image is OK, the others one does not take the height I’ve set

    I’ve already use this and it worked well, so I think I have a bad setting somewhere but I don’t find it.

    (In the link I provide, you will see a custom CSS for the image’s height : this is to have the height I want. But my problem is when I don’t insert this CSS code)

    May you help me, please ?

    Have a nice day !

  • Hi there,

    I checked your site, and the images appear to have consistent heights. Could you provide more details on how you expect the design to appear?

  • Hi, thanks for your reply.

    Indeed, images have a consistent heights and that is that I wish but they have this height because I add this custom CSS :

    @media (min-width:789px){
    .site-main .gb-block-image img{
    	height:250px;
    }
    }

    Usually I just have to set an height in the block editor and it’s ok. But on this particular site, when I do like this, in frontend, the height is set to “auto”.

    And I don’t find where I made a mistake…

  • Hi there,

    you have an image optimizer which is converting the img to a picture
    And that conversion breaks the HTML/CSS classes that GB generates.

    Some style issues can be resolved by setting the picture to display block with this CSS:

    
    picture {
        display: block;
    }
    
  • Hi

    Ah ok, this is Imagify, thanks for this information. Do you advise to not use this conversion of the plugin ?

  • You can use it, it just many require the above CSS or other custom CSS to fix things it may break.
    Any plugin that does the same type of conversion ie. using picture, will have the same result.

  • Ok, thanks a lot for your explanations. Have a nice week-end !

  • You’re welcome – you too!

  • Hi David,

    I re-open this ticket because I have again the same problem. And this time, if I add the css code you provided last time, it does not work and break some design.

    It’s again the “picture” balises from Imagify which do that.

    This time this is for example the border radius that does not work anymore or hover effect.

    Is there a way to make it work ?

  • Usually, the border-radius needs to be added to the img tag nested in the picture tag, rather than to the picture tag itself.

    For this kind of issue, you will need to create a global style (the new global style) to target the img tag in the picture.

    1. create a new global style, start with blank, entre a class for it, eg. picture-image.

    2. click the more button beside more/hover, click +NEW button, add img to the field.
    https://app.screencast.com/FRfLMdG9U4tFt

    3. set the border-radius style for this global style, then apply this global style to the image blocks.

    Let me know if anything is unclear πŸ™‚

  • Hi Ying, thanks for the information, it’s clear πŸ™‚

    But my problme seems more “global” : when I’m using the <picture>’s option tag from Imagify, there are several design’s and effects’ issues after that.

    For example, there is also the “effect” option. Normally on this site, when I hover the article’s image (at te bottom, after the content) the image upscale a little.

    All those effects are not working anymore.

    And when I add the previously provided CSS code
    ‘picture {
    display: block;
    }’

    it breaks some design (for example, on the same block after the main content, title of articles are on the image)

    Do you think I can’t use <picture> tag ?

  • it breaks some design (for example, on the same block after the main content, title of articles are on the image)

    sorry, where can I see the issue?

  • Hi Ying,

    Thanks for your reply. I send you a screenshot and an example page for showing you πŸ™‚

  • Can you try this CSS instead?

    picture {
        display: flex;
    }
    
    picture img {
        object-fit: cover;
    }
  • Hi Ying,

    Thanks a lot it works perfectly πŸ™‚

  • Glad to hear that πŸ™‚

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.