Making WordPress.org

Changeset 12044


Ignore:
Timestamp:
09/02/2022 05:27:26 AM (21 months ago)
Author:
dd32
Message:

WordPress.TV: Include the original uploaded media in the mediaRss component of the RSS feed.

See https://wordpress.slack.com/archives/C037W5MBT/p1661952026609329?thread_ts=1661874607.987119&cid=C037W5MBT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php

    r12042 r12044  
    4747            'featured_wordcamps' => __( 'Featured WordCamps', 'wptv' ),
    4848        ) );
     49
     50        // MediaRSS
     51        // All videos are uploaded by anonvideoupload, we don't need that in the RSS feed.
     52        add_filter( 'mrss_avatar_user', '__return_false' );
     53        // Add the original uploaded file to the mediaRss output.
     54        add_filter( 'mrss_media', array( $this, 'mrss_media_add_original' ) );
    4955    }
    5056
     
    788794        return $locales[ $locale ] ?? false;
    789795    }
     796
     797    /**
     798     * Add the Original uploaded file to the mediaRss output.
     799     */
     800    public function mrss_media_add_original( $meds ) {
     801        global $post;
     802
     803        if ( ! function_exists( 'find_all_videopress_shortcodes' ) ) {
     804            return $meds;
     805        }
     806   
     807        $videos = array_keys( find_all_videopress_shortcodes( $post->post_content ) );
     808        if ( ! $videos ) {
     809            return $meds;
     810        }
     811
     812        $video        = video_get_info_by_guid( $videos[0] );
     813        $original_url = video_attachment_url( $video );
     814
     815        if ( $original_url ) {
     816            $meds[] = array(
     817                'content' => array(
     818                    'attr' => array(
     819                        'medium'    => 'video',
     820                        'isDefault' => 'false',
     821                        'url'       => $original_url,
     822                    )
     823                )
     824            );
     825        }
     826
     827        return $meds;
     828    }
    790829}
    791830
Note: See TracChangeset for help on using the changeset viewer.