Exemplo n.º 1
0
function mtphr_gallery_thumb_ajax()
{
    // Get access to the database
    global $wpdb;
    // Check the nonce
    check_ajax_referer('mtphr_galleries', 'security');
    // Get variables
    $type = $_POST['type'];
    $name_resources = isset($_POST['name_resources']) ? $_POST['name_resources'] : '';
    $attachments = $_POST['attachments'];
    // Display the files
    foreach ($attachments as $attachment) {
        //print_r($attachment);
        if ($attachment['type'] == 'image') {
            if ($type == 'field') {
                mtphr_gallery_admin_render_image_field($attachment, false, $name_resources);
            } else {
                mtphr_gallery_admin_render_image_thumb($attachment['id']);
            }
        } elseif ($attachment['type'] == 'video') {
            if ($type == 'field') {
                mtphr_gallery_admin_render_video_field($attachment, false, $name_resources);
            } else {
                mtphr_gallery_admin_render_video_thumb($attachment['id']);
            }
        } elseif ($attachment['type'] == 'audio') {
            if ($type == 'field') {
                mtphr_gallery_admin_render_audio_field($attachment, false, $name_resources);
            } else {
                mtphr_gallery_admin_render_audio_thumb($attachment['id']);
            }
        }
    }
    die;
    // this is required to return a proper result
}
Exemplo n.º 2
0
 function mtphr_gallery_admin_render_video_field($resource, $pos = 0, $name_resources)
 {
     $thumbnail = isset($resource['poster']) ? $resource['poster'] : '';
     echo '<td class="mtphr-gallery-thumbnail mtphr-gallery-video-thumbnail">';
     echo '<div class="mtphr-gallery-thumbnail-contents">';
     echo '<input class="mtphr-galleries-id" type="hidden" name="' . $name_resources . '[' . $pos . '][id]" data-prefix="' . $name_resources . '" data-param="id" value="' . $resource['id'] . '" />';
     echo '<input class="mtphr-galleries-type" type="hidden" name="' . $name_resources . '[' . $pos . '][type]" data-prefix="' . $name_resources . '" data-param="type" value="video" />';
     echo '<input class="mtphr-galleries-poster" type="hidden" name="' . $name_resources . '[' . $pos . '][poster]" data-prefix="' . $name_resources . '" data-param="poster" value="' . $thumbnail . '" />';
     echo mtphr_gallery_admin_render_video_thumb($thumbnail, $name_resources);
     echo '<div class="mtphr-galleries-admin-thumb-title clearfix">';
     echo '<span>' . get_the_title($resource['id']) . '</span>';
     echo '<span class="mtphr-galleries-admin-thumb-title-type">' . __('Video', 'mtphr-galleries') . '</span>';
     echo mtphr_gallery_admin_preview_button(get_edit_post_link($resource['id']));
     echo mtphr_gallery_admin_delete_button();
     echo '</div>';
     echo '</div>';
     echo '</td>';
 }