jetpack_getty_shortcode

Parse shortcode arguments and render its output.

Description

(string) jetpack_getty_shortcode( (array) $atts, (string) $content = '' ); 

Returns (string)

Parameters (2)

0. $atts (array)
Shortcode parameters.
1. $content — Optional. (string) => ''
Content enclosed by shortcode tags.

Usage

  1. if ( !function_exists( 'jetpack_getty_shortcode' ) ) { 
  2. require_once '/modules/shortcodes/getty.php'; 
  3.  
  4. // Shortcode parameters. 
  5. $atts = array(); 
  6.  
  7. // Content enclosed by shortcode tags. 
  8. $content = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = jetpack_getty_shortcode($atts, $content); 
  12.  

Defined (1)

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

/modules/shortcodes/getty.php  
  1. function jetpack_getty_shortcode( $atts, $content = '' ) { 
  2.  
  3. if ( ! empty( $content ) ) { 
  4. $src = $content; 
  5. } elseif ( ! empty( $atts['src'] ) ) { 
  6. $src = $atts['src']; 
  7. } elseif ( ! empty( $atts[0] ) ) { 
  8. $src = $atts[0]; 
  9. } else { 
  10. return '<!-- Missing Getty Source ID -->'; 
  11.  
  12. $src = preg_replace( '/^(\d+(, \d+)*).*$/', '$1', $src ); 
  13.  
  14. $args = array(); 
  15. $args['width'] = isset( $atts['width'] ) ? (int) $atts['width'] : '462'; 
  16. $args['height'] = isset( $atts['height'] ) ? (int) $atts['height'] : '370'; 
  17.  
  18. return wp_oembed_get( 'https://gty.im/' . $src, $args );