• Resolved Guido

    (@guido07111975)


    Hi,

    I’m still using the Clasic Editor.
    When adding an image to a page that has a caption I notice the width is reduced by 10 pixels. Guess it’s caused by the figure tag. When switching to another theme, this does not occur. Check this temp link.

    Guido

Viewing 15 replies - 1 through 15 (of 17 total)
  • fernandoazarcon2

    (@fernandoazarcon2)

    Hi there,

    Does this occur width or without the caption?

    Thread Starter Guido

    (@guido07111975)

    Hi,

    I have added a link in my previous message, so you can check this yourself.

    Guido

    David

    (@diggeddy)

    Thread Starter Guido

    (@guido07111975)

    Hi David,

    Thanks, will try this. But it seems like this is caused by GP, because with other themes this doesn’t occur.

    Guido

    David

    (@diggeddy)

    I done some digging, and its a legacy filter
    In the old days of the img_caption_shortcode function in WordPress added 10px to the width of a caption image.

    And GP overcame that extra width by removing it here:

    https://github.com/tomusborne/generatepress/blob/513d21a557da677cd02f1a82af5f550f2781618c/inc/general.php#L283

    Subsequently it looks like WP changed there function that means the added 10px no longer gets applied.

    To remedy that, add this snippet to the site to tell GP to NOT remove the 10px.

    add_action('wp', function(){
    	remove_filter( 'img_caption_shortcode_width', 'generate_remove_caption_padding' );	
    });
    Thread Starter Guido

    (@guido07111975)

    Hi David,

    Many thanks for your investigation. This also means that this function will be removed from GP in the near future?

    Guido

    David

    (@diggeddy)

    If only it were as easy as that ??
    We can’t just remove the function as we have backwards compatibility to consider. So we will take under review to see if we can conditionally control it.

    For now either the CSS or the PHP Snippet will be required.

    Thanks for bringing it to our attention.

    • This reply was modified 10 months ago by David.
    Thread Starter Guido

    (@guido07111975)

    Hi David,

    Backwards compatibility support should not be forever. Users should move on.. ??

    When adding the snippet as Element, which hook should I choose? There’s no effect when choosing wp_head and priority 11.

    Guido

    David

    (@diggeddy)

    This article explains how to add that code:

    https://docs.generatepress.com/article/adding-php/

    Thread Starter Guido

    (@guido07111975)

    My client has the Elements feature of GP Premium. But it seems now that I cannot use this feature for a snippet like this?

    Guido

    Leo

    (@leohsiang)

    We cannot answer a question related to premium feature in the free theme support forum here – it’s a WP rule.

    I would recommend going with David’s suggestion above.

    Thread Starter Guido

    (@guido07111975)

    Hi Leo,

    Understood. I will open a topic at the GP Premium forum.

    Guido

    Leo

    (@leohsiang)

    Thanks! I just answered there ??

    Thread Starter Guido

    (@guido07111975)

    @diggeddy / David,

    Subsequently it looks like WP changed there function that means the added 10px no longer gets applied.

    To remedy that, add this snippet to the site to tell GP to NOT remove the 10px.

    Have thought about this some more, but IMO website owners that are using the most recent WP / GP should not be the ones that need a fix for this. If you want to support older WP versions, you could create a fix for that. So not the other way around ??

    Guido

    As i said, we have it under review.
    Once we track down the version where this changed we can look at conditionally loading it.

    • This reply was modified 9 months, 3 weeks ago by David.
Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Caption reduces image width’ is closed to new replies.