Skip to content

Instantly share code, notes, and snippets.

@INDIAN2020
Created May 1, 2013 14:15
Show Gist options
  • Save INDIAN2020/5495487 to your computer and use it in GitHub Desktop.
Save INDIAN2020/5495487 to your computer and use it in GitHub Desktop.
wordpress: image shortcode
/* [image src="" width="" height="" align=""][/image] */
add_shortcode("image","gsn_image");
function gsn_image($atts, $content=''){
extract( shortcode_atts( array(
'src' => 'none',
'content'=> $content,
'width' => '',
'height' => '',
'align' => 'center'
), $atts ) );
$p = ($align != 'center' && $align == 'left') ? 'left;' : 'right;' ;
$output ="<div style='border: 1px solid #CECECE; border-radius: 4px;margin:5px 0;' class='clearfix'><img src='$src' width='$width' height='$height' align='$align' style='margin: 5px' />";
$output .= "<p style='margin: 5px; width:65%; float: $p'>$content</p></div>";
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment