Ticket #23843: 23843.diff
| File 23843.diff, 2.5 KB (added by , 13 years ago) |
|---|
-
wp-includes/media.php
1774 1774 } 1775 1775 1776 1776 /** 1777 * Retrieve audioattached to the passed post1777 * Retrieve media attached to the passed post 1778 1778 * 1779 1779 * @since 3.6.0 1780 1780 * 1781 * @param string $type (Mime) type of media desired 1781 1782 * @param int $post_id Post ID 1782 * @return array Found a udio attachments1783 * @return array Found attachments 1783 1784 */ 1784 function get_attached_ audio($post_id = 0 ) {1785 function get_attached_media( $type, $post_id = 0 ) { 1785 1786 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1786 1787 if ( empty( $post ) ) 1787 1788 return; 1788 1789 1789 $ children = get_children(array(1790 $args = array( 1790 1791 'post_parent' => $post->ID, 1791 1792 'post_type' => 'attachment', 1792 'post_mime_type' => 'audio',1793 'posts_per_page' => -1 1794 ) );1793 'post_mime_type' => $type, 1794 'posts_per_page' => -1, 1795 ); 1795 1796 1796 if ( ! empty( $children ) ) 1797 return $children; 1797 $args = apply_filters( 'get_attached_media_args', $args, $type, $post ); 1798 1799 $children = get_children( $args ); 1800 1801 return (array) apply_filters( 'get_attached_media', $children, $type, $post ); 1798 1802 } 1799 1803 1800 1804 /** 1805 * Retrieve audio attached to the passed post 1806 * 1807 * @since 3.6.0 1808 * 1809 * @param int $post_id Post ID 1810 * @return array Found audio attachments 1811 */ 1812 function get_attached_audio( $post_id = 0 ) { 1813 return get_attached_media( 'audio', $post_id ); 1814 } 1815 1816 /** 1801 1817 * Retrieve video attached to the passed post 1802 1818 * 1803 1819 * @since 3.6.0 … … 1806 1822 * @return array Found video attachments 1807 1823 */ 1808 1824 function get_attached_video( $post_id = 0 ) { 1809 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1810 if ( empty( $post ) ) 1811 return; 1812 1813 $children = get_children( array( 1814 'post_parent' => $post->ID, 1815 'post_type' => 'attachment', 1816 'post_mime_type' => 'video', 1817 'posts_per_page' => -1 1818 ) ); 1819 1820 if ( ! empty( $children ) ) 1821 return $children; 1825 return get_attached_media( 'video', $post_id ); 1822 1826 } 1823 1827 1824 1828 /** … … 2003 2007 * @return array Found image attachments 2004 2008 */ 2005 2009 function get_attached_images( $post_id = 0 ) { 2006 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 2007 if ( empty( $post ) ) 2008 return array(); 2009 2010 $children = get_children( array( 2011 'post_parent' => $post->ID, 2012 'post_type' => 'attachment', 2013 'post_mime_type' => 'image', 2014 'posts_per_page' => -1, 2015 'orderby' => 'menu_order', 2016 'order' => 'ASC' 2017 ) ); 2018 2019 if ( ! empty( $children ) ) 2020 return $children; 2021 2022 return array(); 2010 return get_attached_media( 'image', $post_id ); 2023 2011 } 2024 2012 2025 2013 /**