Skip to content

Instantly share code, notes, and snippets.

@mojowill
Created June 11, 2017 16:25
Show Gist options
  • Save mojowill/8919f1a068d891a05e328ea1cee914ab to your computer and use it in GitHub Desktop.
Save mojowill/8919f1a068d891a05e328ea1cee914ab to your computer and use it in GitHub Desktop.
Fix WordPress margins
<?php
//Remove Stupid 10xp from around the Caption Images
class fixImageMargins{
public $xs = 0; //change this to change the amount of extra spacing
public function __construct(){
add_filter('img_caption_shortcode', array(&$this, 'fixme'), 10, 3);
}
public function fixme($x=null, $attr, $content){
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) ) {
return $content;
}
if ( $id ) $id = 'id="' . $id . '" ';
return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . ((int) $width + $this->xs) . 'px">'
. $content . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment