Changes to LCP Gallery Meta
This commit is contained in:
@ -125,6 +125,30 @@ function validate_media_ids($input) {
|
||||
|
||||
// Return an array of Media IDs
|
||||
function get_media_ids($attributes) {
|
||||
// If post_gallery meta field
|
||||
if (!$attributes['sources'] == "postGallery") {
|
||||
$post_id = get_the_ID();
|
||||
$lcp_post_gallery = get_post_meta( $post_id, 'lcp_gallery', true );
|
||||
|
||||
// Check if the meta field is not empty and unserialize the value
|
||||
if ( ! empty( $lcp_post_gallery ) ) {
|
||||
// Unserialize the meta field value to convert it into an array
|
||||
$gallery_array = $lcp_post_gallery;
|
||||
|
||||
// Initialize an empty array to hold the media IDs
|
||||
$media_ids = array();
|
||||
|
||||
// Loop through the gallery array and extract the media_id values
|
||||
foreach ( $gallery_array as $item ) {
|
||||
// Check if the 'media_id' key exists
|
||||
if ( isset( $item['media_id'] ) ) {
|
||||
$media_ids[] = $item['media_id']; // Add the media_id to the array
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $media_ids;
|
||||
}
|
||||
// Manual Source
|
||||
if ($attributes['source'] == "manual" && isset($attributes['galleryItems'])) {
|
||||
// Extract 'id' from each item in the 'galleryItems' array
|
||||
|
||||
Reference in New Issue
Block a user