jetpack_archiveorg_shortcode

Convert an archive.org shortcode into an embed code.

Description

(string) jetpack_archiveorg_shortcode( (array) $atts ); 

Returns (string)

The embed code for the archive.org video.

Parameters (1)

0. $atts (array)
An array of shortcode attributes.

Usage

  1. if ( !function_exists( 'jetpack_archiveorg_shortcode' ) ) { 
  2. require_once '/modules/shortcodes/archiveorg.php'; 
  3.  
  4. // An array of shortcode attributes. 
  5. $atts = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_archiveorg_shortcode($atts); 
  9.  

Defined (1)

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

/modules/shortcodes/archiveorg.php  
  1. function jetpack_archiveorg_shortcode( $atts ) { 
  2. global $content_width; 
  3.  
  4. if ( isset( $atts[0] ) && empty( $atts['id'] ) ) { 
  5. $atts['id'] = jetpack_shortcode_get_archiveorg_id( $atts ); 
  6.  
  7. $atts = shortcode_atts( array( 
  8. 'id' => '',  
  9. 'width' => 640,  
  10. 'height' => 480,  
  11. 'autoplay' => 0,  
  12. 'poster' => '' 
  13. ), $atts ); 
  14.  
  15. if ( ! $atts['id'] ) { 
  16. return '<!-- error: missing archive.org ID -->'; 
  17.  
  18. $id = $atts['id']; 
  19.  
  20. if ( ! $atts['width'] ) { 
  21. $width = absint( $content_width ); 
  22. } else { 
  23. $width = intval( $atts['width'] ); 
  24.  
  25. if ( ! $atts['height'] ) { 
  26. $height = round( ( $width / 640 ) * 360 ); 
  27. } else { 
  28. $height = intval( $atts['height'] ); 
  29.  
  30. if ( $atts['autoplay'] ) { 
  31. $autoplay = '&autoplay=1'; 
  32. } else { 
  33. $autoplay = ''; 
  34.  
  35. if ( $atts['poster'] ) { 
  36. $poster = '&poster=' . $atts['poster']; 
  37. } else { 
  38. $poster = ''; 
  39.  
  40. $url = esc_url( set_url_scheme( "https://archive.org/embed/{$id}{$autoplay}{$poster}" ) ); 
  41.  
  42. $html = "<div class='embed-archiveorg' style='text-align:center;'><iframe src='$url' width='$width' height='$height' style='border:0;' webkitallowfullscreen='true' mozallowfullscreen='true' allowfullscreen></iframe></div>"; 
  43.  
  44. return $html;