calderawphelpersimage

Class image.

Defined (1)

The class is defined in the following location(s).

/vendor/calderawp/wp-handlebars-helpers/src/image.php  
  1. class image { 
  2. /** 
  3. * Execute the _image Helper for Handlebars.php {{_image image_id size}} 
  4. * based off the IfHelper 
  5. * @param \Handlebars\Template $template The template instance 
  6. * @param \Handlebars\Context $context The current context 
  7. * @param array $args The arguments passed the the helper 
  8. * @param string $source The source 
  9. * @return mixed 
  10. */ 
  11. public static function helper( $template, $context, $args, $source ) { 
  12.  
  13. if( strlen( $args ) <= 0 ) { 
  14. return $context->get( 'image' ); 
  15. $parts = explode(" ", $args); 
  16. $tmp = $context->get( trim( $parts[0] ) ); 
  17. if (isset( $tmp[ 'ID' ] ) ) { 
  18. $url = wp_get_attachment_image_src( $tmp[ 'ID' ] ); 
  19.  
  20.  
  21. } else { 
  22. $url = wp_get_attachment_image_src( $tmp, ( ! empty( $parts[1] ) ? trim( $parts[1] ) : 'thumbnail' ) ); 
  23.  
  24.  
  25. if( is_array( $url ) && isset( $url[0] ) ) { 
  26. return $url[0]; 
  27.  
  28. return null; 
  29.