get_current_blog_id(), 'post_id' => $post_id, ) ); } /** * Look up VideoPress video details by GUID, cached for the request lifetime. * * Wraps wpcom's videopress_get_video_details() so a single feed render that * fans out across two dozen cards only hits the underlying lookup once per * unique GUID. Returns the details object or null on any failure (function * unavailable, bad GUID, WP_Error). Theme is only ever deployed to wpcom * Simple sites where the helper is present. */ function get_videopress_details( $guid ) { static $cache = array(); if ( array_key_exists( $guid, $cache ) ) { return $cache[ $guid ]; } if ( ! function_exists( 'videopress_get_video_details' ) ) { return $cache[ $guid ] = null; } $details = videopress_get_video_details( $guid ); $cache[ $guid ] = ( is_wp_error( $details ) || ! is_object( $details ) ) ? null : $details; return $cache[ $guid ]; } /** * Extract media info from a post for the feed card + lightbox. * * Posts in Renku are typically VideoPress block (most common), single image, * or multi-image gallery. We need a poster (thumb), the playback URL for * videos, and the full image set for galleries. Centralized here so the * render callback and the singular-view JSON emitter stay in sync. * * Returns an array shape: * poster string Best thumbnail URL. * video_src string MP4 URL (empty if no video). * vp_guid string VideoPress GUID (empty if not a VP post). * image_urls array Unique image URLs in document order. * is_gallery bool True when >=2 images and no video. * media_w int Intrinsic media width (0 if unknown). * media_h int Intrinsic media height (0 if unknown). */ function extract_post_media( $post_id ) { $poster = get_post_meta( $post_id, '_renku_poster_url', true ); if ( ! $poster && has_post_thumbnail( $post_id ) ) { $poster = get_the_post_thumbnail_url( $post_id, 'large' ); } $content = get_post_field( 'post_content', $post_id ); // VideoPress: posts using the videopress block render as an iframe to // video.wordpress.com/embed/GUID, so the