function sc_zoom($atts, $content = null) { if (in_shortcode_blogger()) { return ''; } extract(shortcode_atts(array("id" => "", "class" => "", "src" => "", "url" => "", "over" => "", "border" => "none", "align" => "", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)); $s = getStyleString('!' . $top, '!' . $right, '!' . $bottom, '!' . $left, $width, $height); $width = getStyleValue($width); $height = getStyleValue($height); if (empty($id)) { $id = 'sc_zoom_' . str_replace('.', '', mt_rand()); } themerex_enqueue_script('elevate-zoom', themerex_get_file_url('/js/jquery.elevateZoom-3.0.4.min.js'), array(), null, true); $src = $src != '' ? $src : $url; if ($src > 0) { $attach = wp_get_attachment_image_src($src, 'full'); if (isset($attach[0]) && $attach[0] != '') { $src = $attach[0]; } } if ($over > 0) { $attach = wp_get_attachment_image_src($over, 'full'); if (isset($attach[0]) && $attach[0] != '') { $over = $attach[0]; } } return empty($src) ? '' : (!sc_param_is_off($border) ? '<div class="sc_border sc_border_' . $border . '">' : '') . '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_zoom' . (!empty($class) ? ' ' . $class : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>' . '<img src="' . $src . '"' . ($height != '' ? ' style="height:' . $height . ';"' : '') . ' data-zoom-image="' . $over . '" alt="" />' . '</div>' . (!sc_param_is_off($border) ? '</div>' : ''); }
function getStyleString($top = '', $right = '', $bottom = '', $left = '', $width = '', $height = '') { if (!is_array($top)) { $top = compact('top', 'right', 'bottom', 'left', 'width', 'height'); } $output = ''; foreach ($top as $k => $v) { // if $v == 0 -> continue if ($v == 'mini' || $v == 'small' || $v == 'middle' || $v == 'big' || $v == 'large' || $v == '!mini' || $v == '!small' || $v == '!middle' || $v == '!big' || $v == '!large') { continue; } $imp = themerex_substr($v, 0, 1); if ($imp == '!') { $v = themerex_substr($v, 1); } if ($v != '' && $v != 'none') { $output .= ($k == 'width' ? 'width' : ($k == 'height' ? 'height' : 'margin-' . $k)) . ':' . getStyleValue($v) . ($imp == '!' ? ' !important' : '') . ';'; } } return $output; }
function getStyleString($top = '', $right = '', $bottom = '', $left = '', $width = '', $height = '') { if (!is_array($top)) { $top = compact('top', 'right', 'bottom', 'left', 'width', 'height'); } $output = ''; foreach ($top as $k => $v) { $imp = themerex_substr($v, 0, 1); if ($imp == '!') { $v = themerex_substr($v, 1); } if ($v != '') { $output .= ($k == 'width' ? 'width' : ($k == 'height' ? 'height' : 'margin-' . $k)) . ':' . getStyleValue($v) . ($imp == '!' ? ' !important' : '') . ';'; } } return $output; }