vc-single-image.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Testimonials
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Single Image", 'taskereasy'),
  7. "base" => "taskereasy_singelimage",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy single image", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "attach_image",
  15. "heading" => esc_html__("Image", 'taskereasy'),
  16. "param_name" => "image",
  17. ),
  18. array(
  19. "type" => "dropdown",
  20. "heading" => esc_html__("Size", 'taskereasy'),
  21. "param_name" => "image_size",
  22. "value" => array('Full' => 'full', 'Medium' => 'medium', 'Thumbnail' => 'thumbnail' ),
  23. ),
  24. array(
  25. 'type' => 'css_editor',
  26. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  27. 'param_name' => 'custom_design',
  28. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  29. )
  30. )
  31. )
  32. );
  33. add_shortcode( 'taskereasy_singelimage', function($atts, $content = null) {
  34. extract(shortcode_atts(array(
  35. 'image' => '',
  36. 'image_size' => 'full',
  37. 'custom_design' => '',
  38. ), $atts));
  39. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  40. $output = '';
  41. $image = html_entity_decode(vc_value_from_safe($image, true));
  42. $img_size = html_entity_decode(vc_value_from_safe($image_size, true));
  43. $image_url = wp_get_attachment_image_src( $image, $img_size );
  44. $output .='
  45. <div class="single-image-section image-'.esc_attr($img_size).' '.esc_attr($custom_design).'">
  46. <div class="vc-image">
  47. <img src="'.esc_url($image_url[0]).'" alt="image">
  48. </div>';
  49. $output .='</div>';
  50. return $output;
  51. });