コード例 #1
0
 public function multiple_images($id, $label, $desc = '')
 {
     global $post;
     $html = '';
     $html = '';
     $html .= '<div class="cmo_metabox_field">';
     $html .= '<div class="cmo_desc">';
     $html .= '<label for="cmo_' . $id . '">';
     $html .= $label;
     $html .= '</label>';
     if ($desc) {
         $html .= '<p>' . $desc . '</p>';
     }
     $html .= '</div>';
     $html .= '<div class="cmo_field">';
     $html .= '<div class="cmo_multiple_images" data-formid="' . $id . '">';
     $html .= '<div class="cmo_multiple_image_button_container"><input class="cmo_multiple_upload_button" type="button" value="' . __('Add Images', 'cumulo') . '" /></div>';
     $html .= '<div class="cmo_uploaded_images clearfix">';
     $html .= '<input type="hidden" id="cmo_' . $id . '_first" name="cmo_' . $id . '[]" value="__">';
     $selected_image = cmo_get_val_from_array(get_post_meta($post->ID, 'cmo_' . $id, false));
     $i = 0;
     if (is_array($selected_image)) {
         foreach ($selected_image as $image_id) {
             $i++;
             if ($i == 1) {
                 continue;
             }
             $image = cmo_get_val_from_array(wp_get_attachment_image_src($image_id));
             $html .= '<div class="image">';
             $html .= '<img src="' . $image . '">';
             $html .= '<input type="hidden" id="cmo_' . $id . '" name="cmo_' . $id . '[]" value="' . $image_id . '">';
             $html .= '<i class="remove fa fa-close"></i>';
             $html .= '</div>';
         }
     }
     $html .= '</div>';
     $html .= '</div>';
     $html .= '</div>';
     $html .= '</div>';
     echo $html;
 }
コード例 #2
0
ファイル: metabox.php プロジェクト: supahseppe/ashley-travel
function fg_display_metabox()
{
    global $post;
    // Get the Information data if its already been entered
    $galleryHTML = '';
    $oldfix = '';
    if (get_bloginfo('version') >= 3.8) {
        $button = '<button>&#xf335;</button>';
    } else {
        $button = '<button class="media-modal-icon"></button>';
        $oldfix = ' premp6';
    }
    $selectText = __('Select Images', 'cumulo');
    $visible = '';
    //SHOULD WE SHOW THE REMOVE ALL BUTTON? THIS WILL BE APPLIED AS A CLASS, AND IS BLANK BY DEFAULT.
    $galleryArray = get_post_gallery_ids($post->ID);
    $galleryString = get_post_gallery_ids($post->ID, 'string');
    if (!empty($galleryString)) {
        foreach ($galleryArray as &$id) {
            $galleryHTML .= '<li>' . $button . '<img id="' . $id . '" src="' . cmo_get_val_from_array(wp_get_attachment_image_src($id)) . '"></li> ';
        }
        $selectText = __('Edit Selection', 'cumulo');
        $visible = " visible";
    }
    update_post_meta($post->ID, 'fg_temp_metadata', $galleryString);
    // Overwrite the temporary featured gallery data with the permanent data. This is a precaution in case someone clicks Preview Changes, then exits withing saving.
    ?>

	<input type="hidden" name="fg_temp_noncedata" id="fg_temp_noncedata" value="<?php 
    echo wp_create_nonce('fg_temp_noncevalue');
    ?>
" />

	<input type="hidden" name="fg_perm_noncedata" id="fg_perm_noncedata" value="<?php 
    echo wp_create_nonce(plugin_basename(__FILE__));
    ?>
" />

	<input type="hidden" name="fg_perm_metadata" id="fg_perm_metadata" value="<?php 
    echo esc_attr($galleryString);
    ?>
" data-post_id="<?php 
    echo esc_attr($post->ID);
    ?>
" />

	<button class="button" id="fg_select"><?php 
    echo esc_html($selectText);
    ?>
</button>

	<button class="button<?php 
    echo esc_attr($visible) . esc_attr($oldfix);
    ?>
" id="fg_removeall"><?php 
    _e('Remove All', 'cumulo');
    ?>
</button>

	<ul><?php 
    echo $galleryHTML;
    ?>
</ul>

	<div style="clear:both;"></div><?php 
}
コード例 #3
0
<?php

$cmo_featured_images = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full');
$cmo_featured_image = "";
if (sizeof($cmo_featured_images) > 0) {
    $cmo_featured_image = $cmo_featured_images[0];
}
if (empty($cmo_featured_image)) {
    $ids = get_post_gallery_ids(get_the_ID());
    $ids = array_filter($ids);
    if ($ids && count($ids) > 0) {
        $cmo_featured_image = cmo_get_val_from_array(wp_get_attachment_image_src($ids[0], "full"));
    }
}
$sizes = array('x', 'x');
$sizeMeta = get_post_meta(get_the_ID(), "cmo_featured_image_masonry_size");
if ($sizeMeta) {
    $sizes = explode('_', $sizeMeta[0]);
}
$ext_link = "";
$extlinkMeta = get_post_meta(get_the_ID(), "cmo_portfolio_demo");
if ($extlinkMeta) {
    $ext_link = trim($extlinkMeta[0]);
}
?>
<article id="<?php 
the_ID();
?>
" <?php 
post_class(array("cmo-portfolio-item", "cmo-post-in-list", "cmo-portfolio-width-" . $sizes[0], "cmo-portfolio-height-" . $sizes[1]));
?>