| @@ -1,48 +1,37 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; | |
| 4 | -} | |
| 5 | -use EBS\Security\Sanitizer; | |
| 6 | 2 | |
| 7 | 3 | /* * ********************************************************* |
| 8 | 4 | * BUTTONS |
| 9 | 5 | * ********************************************************* */ |
| 10 | 6 | |
| 11 | -function osc_theme_oscitasthumbnail( $params, $content = 'Label' ) { | |
| 12 | - $atts = shortcode_atts( | |
| 13 | - array( | |
| 14 | - 'src' => '', | |
| 15 | - 'class' => '', | |
| 16 | - 'link' => '', | |
| 17 | - 'border' => '', | |
| 18 | - 'target' => '_self', | |
| 19 | - 'alt' => '', | |
| 20 | - ), | |
| 21 | - $params | |
| 22 | - ); | |
| 7 | +function osc_theme_oscitasthumbnail($params, $content = 'Label') { | |
| 8 | + extract(shortcode_atts(array( | |
| 9 | + 'src' => '', | |
| 10 | + 'class' => '', | |
| 11 | + 'link' => '', | |
| 12 | + 'border'=>'' | |
| 13 | + ), $params)); | |
| 14 | + $out = ''; | |
| 15 | + $borderClass = ''; | |
| 16 | + $imageBorderClass = 'img-responsive'; | |
| 17 | + if ($border != '') { | |
| 18 | + $borderClass = 'img-thumbnail '; | |
| 19 | + } | |
| 23 | 20 | |
| 24 | - $out = ''; | |
| 25 | - $src = Sanitizer::url( $atts['src'] ); | |
| 26 | - $class = Sanitizer::class_list( $atts['class'] ); | |
| 27 | - $link = Sanitizer::url( $atts['link'] ); | |
| 28 | - $alt = Sanitizer::attr( $atts['alt'] ); | |
| 29 | - $target = '_blank' === $atts['target'] ? '_blank' : '_self'; | |
| 21 | + $out = ' <div class="' . $borderClass.$class . '">'; | |
| 30 | 22 | |
| 31 | - if ( '' !== $atts['border'] ) { | |
| 32 | - $border_class = 'img-thumbnail'; | |
| 33 | - } else { | |
| 34 | - $border_class = 'img-responsive'; | |
| 35 | - } | |
| 23 | + //$out = ' <div class="img-thumbnail ' . $class . '">'; | |
| 24 | + if ($link != '') { | |
| 25 | + $out .='<a href="' . $link . '">'; | |
| 26 | + } | |
| 27 | + $out .= '<img src="' . $src . '" '.($imageBorderClass? ' class="'.$imageBorderClass.'"':'').'>'; | |
| 28 | + if ($link != '') { | |
| 29 | + $out .='</a>'; | |
| 30 | + } | |
| 36 | 31 | |
| 37 | - if ( '' !== $atts['link'] ) { | |
| 38 | - $out .= '<a href="' . $link . '" target="' . Sanitizer::attr( $target ) . '">'; | |
| 39 | - } | |
| 40 | - $out .= '<img src="' . $src . '" class="' . $border_class . EBS_CONTAINER_CLASS . ' oscitas-res-image" alt="' . $alt . '">'; | |
| 41 | - if ( '' !== $atts['link'] ) { | |
| 42 | - $out .= '</a>'; | |
| 43 | - } | |
| 32 | + $out .= '</div>'; | |
| 33 | + return $out; | |
| 34 | +} | |
| 44 | 35 | |
| 45 | - return $out; | |
| 46 | -} | |
| 36 | +add_shortcode('thumbnail', 'osc_theme_oscitasthumbnail'); | |
| 47 | 37 | |
| 48 | -ebs_backward_compatibility_callback( 'thumbnail', 'osc_theme_oscitasthumbnail' ); | |