Created
October 4, 2022 13:29
-
-
Save GLWalker/d6949859d2da33c8ff723c8328901e7e to your computer and use it in GitHub Desktop.
WordPress Pods Embed & Google Drive Videos BootStrap 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Output embedded videos | |
* wraps embed in Bootstrap Markup | |
* Pod field is repeatable "oembed" named video_url | |
* @example embeded_videos($user->ID); | |
* @param [type] $user as object ID | |
*/ | |
function embeded_videos($user) | |
{ | |
// Setup pod object for extended user - | |
// change to use your pod name and object ID | |
$pod = pods('user', $user); | |
$video_url = $pod->field('video_url'); | |
//loop through related field if not empty, create needed markup | |
if (!empty($video_url)) { ?> | |
<div class="row"> | |
<?php | |
foreach ($video_url as $url) { | |
echo '<div class="col-md-6 col-12 mb-4">' . | |
' <div class="ratio ratio-16x9">' . | |
wp_oembed_get($url, array('width' => 640, 'height' => 480)) . | |
' </div>' . | |
'</div>'; | |
} //end of foreach | |
?> | |
</div> | |
<?php | |
} | |
} | |
/** | |
* Output google drive as embedded url | |
* wraps iframe in Bootstrap Markup | |
* Google Drive url must not have anything after the ending _ underscore. | |
* Pod field is repeatable "URL" named google_drive_videos | |
* @example google_drive_embed($user->ID); | |
* @param [type] $user as object ID | |
*/ | |
function google_drive_embed($user) | |
{ | |
//Setup or pod object for extended user - | |
// change to use your pod name and object ID | |
$pod = pods('user', $user); | |
$google_drive = $pod->field('google_drive_videos'); | |
//loop through related field if not empty, create needed markup | |
if (!empty($google_drive)) { ?> | |
<div class="row"> | |
<?php | |
foreach ($google_drive as $url) { | |
echo '<div class="col-md-6 col-12 mb-4">' . | |
' <div class="ratio ratio-16x9">' . | |
' <iframe src="' . $url . '/preview" width="640" height="480" allow="autoplay"></iframe>' . | |
' </div>' . | |
'</div>'; | |
} //end of foreach | |
?> | |
</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment