Should I edit media.php? (5 posts)

  1. avalera
    Posted 7 years ago #

    In the file media.php line 581 fucntion img_caption_shortcode

    return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">

    What can I do if I don't want those 10 extra pixels in the width? I know I can delete it and that's what I did, but when I update WP, it will be replaced.

    BTW those 10 pixels are render in the div of wach attachment.

    <div id="attachment_563" class="wp-caption aligncenter" style="width: 310px">

    The image with is 300 and the width it's set to 310.

    Is there a better way do it?

  2. kove
    Posted 6 years ago #

    I think developers should remove that +10px, I've seen many people complaining about it, and i'm too.

    BTW, why there is that "additional 10px" ?

  3. Aldi
    Posted 6 years ago #

    There're two workarounds for this:

    Hope these help! Cheers!!

  4. chartinael
    Posted 6 years ago #

    I changed it as well ... here is my version ... is a bit annoyin on the left hand side but hey, I live with it ... and redo after updating. I'd prefer setting the style somewhere else but nothing have worked so far.

    change to:

    $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title).'" '.$hwstring.' class="'.$class.'" style="padding-left: 10px;" />';

    653ff :

    '<div ' . $id . 'class="' . $align . '" style="text-align:center;">'. do_shortcode( $content ) . '
    <span class="wp-caption-text" style="position:relative;width:'. $width . 'px;padding-left:10px; display:inline-block;text-align:left;">
    <small>' . $caption . '</small>

    What this does ... gives me a padding and adds a caption left aligned.

  5. chartinael
    Posted 6 years ago #

    Hey, I think workaround one will be a nice solution to my meddling with media php....

    I think I will fiddle with that in the near future.

Topic Closed

This topic has been closed to new replies.

About this Topic