themehybrid / hybrid-core

Official repository for the Hybrid Core WordPress development framework.
GNU General Public License v2.0
689 stars 144 forks source link

hybrid_get_post_media returns video on video post format even if type audio is requested #152

Closed sharmashivanand closed 6 years ago

sharmashivanand commented 6 years ago

Steps to duplicate: Place the following in content.php content template.

echo ( $audio = hybrid_get_post_media( array( 'type' => 'audio', 'split_media' => true ) ) );

Result: Returns the video media on video post format. Expected result: Return audio media or no media at all.

justintadlock commented 6 years ago

This doesn't really have anything to do with the post format. It's about the type argument.

But, this is a known issue with some types of media. At the moment, there's no way to distinguish certain items from others.

justintadlock commented 6 years ago

This should now be better handled in the 5.0 branch. It needs testing.

The equivalent of your code above would be:

echo ( $audio = Hybrid\get_post_media( [ 'type' => 'audio', 'split' => true ] ) );
justintadlock commented 6 years ago

This should be better now. Only the [embed], [playlist] and auto-embeds aren't covered because they're not specific to any type of media. Those work for both audio and video embeds. I'm not sure how to work around those specifically.

This is going to be a soft close. I'd be happy to reopen with ideas on how to specifically address those 3 cases.