Changeset 23776
- Timestamp:
- 03/22/2013 08:08:46 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/media.php
r23774 r23776 1775 1775 1776 1776 /** 1777 * Retrieve audio attached to the passed post 1778 * 1779 * @since 3.6.0 1780 * 1777 * Retrieve media attached to the passed post 1778 * 1779 * @since 3.6.0 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 */ 1784 function get_attached_ audio($post_id = 0 ) {1783 * @return array Found attachments 1784 */ 1785 function get_attached_ $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 $ array( 1790 1791 'post_parent' => $post->ID, 1791 1792 'post_type' => 'attachment', 1792 'post_mime_type' => 'audio', 1793 'posts_per_page' => -1 1794 ) ); 1795 1796 if ( ! empty( $children ) ) 1797 return $children; 1793 'post_mime_type' => $type, 1794 'posts_per_page' => -1, 1795 'orderby' => 'menu_order', 1796 'order' => 'ASC', 1797 ); 1798 1799 $args = apply_filters( 'get_attached_media_args', $args, $type, $post ); 1800 1801 $children = get_children( $args ); 1802 1803 return (array) apply_filters( 'get_attached_media', $children, $type, $post ); 1804 } 1805 1806 /** 1807 * Retrieve audio attached to the passed post 1808 * 1809 * @since 3.6.0 1810 * 1811 * @param int $post_id Post ID 1812 * @return array Found audio attachments 1813 */ 1814 function get_attached_audio( $post_id = 0 ) { 1815 return get_attached_media( 'audio', $post_id ); 1798 1816 } 1799 1817 … … 1807 1825 */ 1808 1826 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; 1827 return get_attached_media( 'video', $post_id ); 1822 1828 } 1823 1829 … … 2004 2010 */ 2005 2011 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(); 2012 return get_attached_media( 'image', $post_id ); 2023 2013 } 2024 2014
Note: See TracChangeset
for help on using the changeset viewer.