The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Media Format Code checker or something? (5 posts)

  1. MCM
    Posted 3 years ago #

    Is there some podpress code that I can run that will return the format of media file attached to that post?

    I would like to check if the file is for example an MP3 then I want to show a MP3 Image next to the title like a tumblog style thing.


  2. ntm
    Plugin Author

    Posted 3 years ago #

    The podPress HTML element in the blog posts have class names according to the embedded media file e.g. podPress_content_audio_mp3.

    Or you could use podPress Filter hooks and parse the output of podPress for these class names.
    possible filter hooks are:

    • podpress_downloadlinks (for the element below the player)
    • podpress_post_scriptblock (the JS which is necessary to initialize the player)
    • podpress_post_content (the complete podPress output per post)

    A further possibility is to make an own db query. You would need to know the ID of the current post. With the post ID, you could look in the wp_postmeta table whether the post has meta data with the meta_key _podPressMedia. The content of these db entries is a serialized array. These strings/arrays contains the mime type in form of a string which starts with audio_ if it is an entry for an audio attachment.

  3. MCM
    Posted 3 years ago #

    Can you provide me with some help with this? I have tried googling to find a way to check for values inside the_content.

    I have looked at the codex pages around post_class.

    Am I on the right track?

    add_filter( 'the_content', 'podcast_get_media_type' );
    function podcast_get_media_type() {
    	$htmlString = '<html>...</html>';//either generated, or loaded from a file
    	$dom = new DOMDocument;
    	$dom->loadHTML($htmlString);//or loadHTMLFile
    	$divs = $dom->getElementsByTagName('div');
    	foreach($divs as $div)
    		if ($div->hasAttribute('class') && strstr($div->getAttribute('class'), 'podPress_content podPress_content_audio_mp3'))
    			echo 'has mp3 file';
    		echo $divs;
  4. MCM
    Posted 3 years ago #

    This works but it is displaying the echo twice, any ideas?

    add_filter( 'podpress_post_content', 'podcast_get_media_type' );
    function podcast_get_media_type($content) {
    	 if(strpos($content, 'podPress_content podPress_content_audio_mp3'))
            echo 'Stream or Download this Audio or subscribe to our Podcasts for this Speaker (if available)';
        } else {
            echo 'it does NOT work';
    	return $content;
  5. MCM
    Posted 3 years ago #

    removed the echo's :) Thanks for your initial feedback apologies for the updates at least others know how to get this done.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.