EstudioJuridicoAlmagro_Web/www/wpv_common/shortcodes/images.php
2013-03-01 18:06:10 +00:00

72 lines
1.5 KiB
PHP

<?php
/**
* displays an image
*
* default sizes: small, medium, blog
* icons: zoom, doc, play
*/
function wpv_shortcode_image($atts, $content = null, $code) {
extract(shortcode_atts(array(
'size' => 'medium',
'link' => '#',
'lightbox' => 'false',
'title' => '',
'align' => false,
'group' => '',
'width' => false,
'height' => false,
'autoheight' => 'false',
'quality' => false,
'frame' => false,
'link_class' => '',
'underline' => 'true',
), $atts));
$width = (int)$width;
$height = (int)$height;
if( !$width && !$height) {
$width = wpv_get_option('image_' . $size.'_width');
$height = wpv_get_option('image_' . $size.'_height');
if(!$width)
$width = 150;
if(!$height)
$height = 150;
}
if($autoheight=='true')
$height = '';
$src = trim($content);
$no_link = '';
if($lightbox == 'true') {
if($link == '#')
$link = $src;
} elseif(empty($link))
$no_link = ' image_no_link';
$class = '';
$class .= ($frame == 'true') ? 'framed' : 'not-framed';
$quality = empty($quality) ? null : $quality;
$image_options = array(
'width' => $width,
'height' => $height,
'class' => $class,
);
$src = wpv_resize_image($src, $width, $height, $quality);
$image = wpv_get_lazy_load($src, $title, $image_options);
ob_start();
include WPV_SHORTCODE_TEMPLATES . 'images.php';
return ob_get_clean();
}
add_shortcode('image', 'wpv_shortcode_image');