Site logo

[Resolved] Caption Text overlapping

Home Forums Support [Resolved] Caption Text overlapping

Home Forums Support Caption Text overlapping

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2439614
    Henry

    Longer Texts on image caption overlaps on mobile view. Below is the code used for image caption.

    Here’s Sample link. Kindly view on mobile : https://scholarsly.com/how-old-is-ranboo-net-worth-real-name-how-tall-face/

    add_filter( 'post_thumbnail_html', 'custom_add_post_thumbnail_caption',10,5 );
     
    function custom_add_post_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr) {
     
    if( $html == '' || ! is_single() || ! is_main_query() ) {
      
        return $html;
      
    } else {
      
        $out = '';
      
        $thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment'));
      
        if ($thumbnail_image && isset($thumbnail_image[0])) {
      
            $image = wp_get_attachment_image_src($post_thumbnail_id, $size);
     
            if($thumbnail_image[0]->post_excerpt) 
                $out .= '<div class="wp-caption thumb-caption">';
      
            $out .= $html;
      
            if($thumbnail_image[0]->post_excerpt) 
                $out .= '<p class="wp-caption-text thumb-caption-text">'.$thumbnail_image[0]->post_excerpt.'</p></div>';
       
        }
     
        return $out;
       
    }
    }
    #2439689
    Leo
    Staff
    Customer Support

    Hi there,

    Can you add this CSS?

    .wp-caption .wp-caption-text {
        line-height: 1.5;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    Let me know if this helps 🙂

    #2440671
    Henry

    Thanks Leo,

    Problem solved.

    #2441696
    Leo
    Staff
    Customer Support

    No problem 🙂

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