Example #1
0
/**
 * Gets the "transcript" for an audio attachment.  This is typically saved as "unsynchronised_lyric", which is
 * the ID3 tag sanitized by WordPress.
 *
 * @since  2.0.0
 * @access public
 * @param  int     $post_id
 * @return string
 */
function hybrid_get_audio_transcript($post_id = 0)
{
    return hybrid_get_media_meta('lyrics', array('wrap' => '', 'post_id' => $post_id ? $post_id : get_the_ID()));
}
Example #2
0
/**
 * Adds a section below the player to  display the video file information (toggled by custom JS).
 *
 * @since  1.0.0
 * @access public
 * @param  string  $html
 * @param  array   $atts
 * @param  object  $audio
 * @return string
 */
function stargazer_video_shortcode($html, $atts, $video)
{
    // Don't show on single attachment pages or in the admin.
    if (is_attachment() || is_admin()) {
        return $html;
    }
    // If we have an actual attachment to work with, use the ID.
    if (is_object($video)) {
        $attachment_id = $video->ID;
    } else {
        $extensions = join('|', wp_get_video_extensions());
        preg_match('/(src|' . $extensions . ')=[\'"](.+?)[\'"]/i', preg_replace('/(\\?_=[0-9])/i', '', $html), $matches);
        if (!empty($matches)) {
            $attachment_id = stargazer_get_attachment_id_from_url($matches[2]);
        }
    }
    // If an attachment ID was found, add the media info section.
    if (!empty($attachment_id)) {
        $html .= '<div class="media-shortcode-extend">';
        $html .= '<div class="media-info video-info">';
        $html .= '<ul class="media-meta">';
        $pre = '<li><span class="prep">%s</span>';
        $html .= hybrid_get_media_meta('length_formatted', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Run Time', 'stargazer')), 'after' => '</li>'));
        $html .= hybrid_get_media_meta('dimensions', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Dimensions', 'stargazer')), 'after' => '</li>'));
        $html .= hybrid_get_media_meta('file_type', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('File Type', 'stargazer')), 'after' => '</li>'));
        $html .= hybrid_get_media_meta('file_name', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('File Name', 'stargazer')), 'after' => '</li>'));
        $html .= hybrid_get_media_meta('mime_type', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Mime Type', 'stargazer')), 'after' => '</li>'));
        $html .= '</ul></div>';
        $html .= '<button class="media-info-toggle">' . __('Video Info', 'stargazer') . '</button>';
        $html .= '</div>';
    }
    return $html;
}