admin管理员组文章数量:1130349
I created a function which gets the metadata video length from the selected attachment. I use this together with a plugin called multisite-global-media which lets me share media from a site to all other sites in the multisite network. But selecting a video from this media site will break my function, as I am not able to pull the metadata from attached media from the other site except if I use the switch_to_blog function.
But I need to determine if the selected media is from the current site or from the media site.
This is what I am working on:
switch_to_blog($attachment_site);
$attachment_id = attachment_url_to_postid( $_POST[ 'background-video' ] );
$video_meta = get_post_meta( $attachment_id , '_wp_attachment_metadata', true );
restore_current_blog();
if( isset( $_POST[ 'background-video' ] ) && $video_meta['length'] >= 1 ) {
update_post_meta( $post_id, 'slide_duration', $video_meta['length'] );
}
What I need to do is to get the $attachment_site somehow.
Any idea how?
EDIT:
if( isset( $_POST[ 'background-video' ] ) ) {
update_post_meta( $post_id, 'background-video', $_POST[ 'background-video' ] );
}
I created a function which gets the metadata video length from the selected attachment. I use this together with a plugin called multisite-global-media which lets me share media from a site to all other sites in the multisite network. But selecting a video from this media site will break my function, as I am not able to pull the metadata from attached media from the other site except if I use the switch_to_blog function.
But I need to determine if the selected media is from the current site or from the media site.
This is what I am working on:
switch_to_blog($attachment_site);
$attachment_id = attachment_url_to_postid( $_POST[ 'background-video' ] );
$video_meta = get_post_meta( $attachment_id , '_wp_attachment_metadata', true );
restore_current_blog();
if( isset( $_POST[ 'background-video' ] ) && $video_meta['length'] >= 1 ) {
update_post_meta( $post_id, 'slide_duration', $video_meta['length'] );
}
What I need to do is to get the $attachment_site somehow.
Any idea how?
EDIT:
if( isset( $_POST[ 'background-video' ] ) ) {
update_post_meta( $post_id, 'background-video', $_POST[ 'background-video' ] );
}
本文标签: customizationGet site ID from attachment url
版权声明:本文标题:customization - Get site ID from attachment url? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749162733a2325663.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论