function mtheme_portfolio_custom_columns($column)
 {
     global $post;
     $custom = get_post_custom();
     $image_url = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));
     $full_image_id = get_post_thumbnail_id($post->ID, 'thumbnail');
     $full_image_url = wp_get_attachment_image_src($full_image_id, 'thumbnail');
     $full_image_url = $full_image_url[0];
     if (!defined('MTHEME')) {
         $mtheme_shortname = "mtheme_p2";
         define('MTHEME', $mtheme_shortname);
     }
     switch ($column) {
         case "portfolio_image":
             if (isset($image_url)) {
                 echo '<a class="thickbox" href="' . $full_image_url . '"><img src="' . $image_url . '" width="60px" height="60px" alt="featured" /></a>';
             } else {
                 echo __('Image not found', 'mthemelocal');
             }
             break;
         case "description":
             if (isset($custom[MTHEME . '_thumbnail_desc'][0])) {
                 echo $custom[MTHEME . '_thumbnail_desc'][0];
             }
             break;
         case "video":
             if (isset($custom[MTHEME . '_lightbox_video'][0])) {
                 echo $custom[MTHEME . '_lightbox_video'][0];
             }
             break;
         case "types":
             echo get_the_term_list($post->ID, 'types', '', ', ', '');
             break;
     }
 }
 function mtheme_fullscreen_custom_columns($column)
 {
     global $post;
     $custom = get_post_custom();
     $image_url = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));
     $full_image_id = get_post_thumbnail_id($post->ID, 'thumbnail');
     $full_image_url = wp_get_attachment_image_src($full_image_id, 'thumbnail');
     $full_image_url = $full_image_url[0];
     if (!defined('MTHEME')) {
         $mtheme_shortname = "mtheme_p2";
         define('MTHEME', $mtheme_shortname);
     }
     switch ($column) {
         case "featured_image":
             if (isset($image_url)) {
                 echo '<a class="thickbox" href="' . $full_image_url . '"><img src="' . $image_url . '" width="40px" height="40px" alt="featured" /></a>';
             } else {
                 echo 'Image not found';
             }
             break;
         case "featured_description":
             if (isset($custom["featured_description"][0])) {
                 echo $custom["featured_description"][0];
             }
             break;
         case "fullscreen_type":
             if (isset($custom["fullscreen_type"][0])) {
                 echo $custom["fullscreen_type"][0];
             }
             break;
     }
 }
Ejemplo n.º 3
0
function display_images_from_media_library($type, $mediaID = NULL)
{
    if ($type == 'bg') {
        $thumb_type = 'st-bg-thumb';
    } else {
        $thumb_type = 'st-thumb';
    }
    if ($mediaID == NULL || $mediaID == 0) {
        $image_return = '<img style="opacity: 1; filter: alpha(opacity=100);" width="80" height="80" class="thumb ' . $thumb_type . '" src="' . plugins_url('images/no-image.png', __FILE__) . '" alt="" data-pid="" />';
    } else {
        $image_return = '<img style="opacity: 0.2; filter: alpha(opacity=2);" width="80" height="80" class="thumb ' . $thumb_type . '" src="' . plugins_url('images/no-image.png', __FILE__) . '" alt="" data-pid="" />';
    }
    $images = get_children(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'));
    if ($images) {
        foreach ($images as $id => $image) {
            $opacity_out = 'style="opacity: 0.2; filter: alpha(opacity=2);"';
            if ($mediaID !== NULL) {
                if ($image->ID == $mediaID) {
                    $opacity_out = 'style="opacity: 1; filter: alpha(opacity=100);"';
                }
            }
            $img = wp_get_attachment_thumb_url($image->ID);
            $image_return .= '<img ' . @$opacity_out . 'width="80" height="80" class="thumb ' . $thumb_type . '" src="' . $img . '" alt="" data-pid="' . $image->ID . '" />';
        }
    }
    return $image_return;
}
Ejemplo n.º 4
0
 /**
  * Check AM_MBF for description.
  *
  * @todo Set class on div to set if the image has been selected and get rid of $hide_upload_button and $hide_clear_button.
  *
  * @since 1.0.0
  */
 public function output()
 {
     // Get the file id, 0 represents a new field.
     $image_id = intval($this->value) > 0 ? intval($this->value) : 0;
     $image_url = '';
     $image_title = '';
     $class_icon = '';
     $hide_upload_button = $hide_clear_button = ' style="display:none;"';
     // Make sure the selected image is valid.
     if ($image_id > 0) {
         $post = get_post($image_id);
         if (isset($post) && wp_attachment_is_image($image_id)) {
             $image_url = wp_get_attachment_thumb_url($image_id);
             $image_title = $post->post_title;
         } else {
             $this->error = __(sprintf('Selected Image (ID:%1$d) is invalid.', $image_id), 'am-cpts');
             $class_icon = ' invalid';
         }
         $hide_clear_button = '';
     } else {
         $hide_upload_button = '';
     }
     // Text used by wp.media frame.
     $wp_media_data = sprintf(' data-title="%1$s" data-button="%2$s"', esc_attr__('Choose an Image', 'am-cpts'), esc_attr__('Use this Image', 'am-cpts'));
     return sprintf('
   <div%11$s>
     <input name="%2$s" type="hidden" class="meta-box-upload-image" value="%1$d"%12$s />
     <img src="%10$s" class="meta-box-preview-image%3$s" title="%7$s" alt="%6$s"%5$s />
     <a href="#" class="meta-box-upload-image-button button"%4$s%13$s>%8$s</a>
     <span class="meta-box-image-title"%5$s>%6$s</span>
     <a href="#" class="meta-box-clear-image-button"%5$s>%9$s</a>
   </div>', esc_attr($image_id), esc_attr($this->name), $class_icon, $hide_upload_button, $hide_clear_button, isset($this->error) ? esc_html($this->error) : $image_title, esc_attr__('Selected Image', 'am-cpts'), esc_html__('Choose Image', 'am-cpts'), esc_html__('Remove Image', 'am-cpts'), esc_url($image_url), $this->get_classes('meta-box-image'), $this->get_data_atts(), $wp_media_data);
 }
Ejemplo n.º 5
0
/**
 * Display Sort admin
 *
 * @return void
 * @author Soul
 **/
function mtheme_sort_portfolio()
{
    $portfolio = new WP_Query('post_type=mtheme_portfolio&posts_per_page=-1&orderby=menu_order&order=ASC');
    ?>
	<div class="wrap">
	<h2>Sort portfolio Slides<img src="<?php 
    echo home_url();
    ?>
/wp-admin/images/loading.gif" id="loading-animation" /></h2>
	<div class="description">
	Drag and Drop the slides to order them
	</div>
	<ul id="portfolio-list">
	<?php 
    while ($portfolio->have_posts()) {
        $portfolio->the_post();
        ?>
		<li id="<?php 
        the_id();
        ?>
">
		<div>
		<?php 
        $image_url = wp_get_attachment_thumb_url(get_post_thumbnail_id());
        $custom = get_post_custom(get_the_ID());
        $portfolio_cats = get_the_terms(get_the_ID(), 'types');
        ?>
		<?php 
        if ($image_url) {
            echo '<img class="mtheme_admin_sort_image" src="' . $image_url . '" width="30px" height="30px" alt="" />';
        }
        ?>
		<span class="mtheme_admin_sort_title"><?php 
        the_title();
        ?>
</span>
		<?php 
        if ($portfolio_cats) {
            ?>
		<span class="mtheme_admin_sort_categories"><?php 
            foreach ($portfolio_cats as $taxonomy) {
                echo ' | ' . $taxonomy->name;
            }
            ?>
</span>
		<?php 
        }
        ?>
		</div>

		</li>
	<?php 
    }
    ?>
	</div><!-- End div#wrap //-->
 
<?php 
}
Ejemplo n.º 6
0
/**
 * Shortcode function for Lightbox2
 *
 * @see [lightbox name="gallery" post="1"]
 * @param $atts
 * @param null $content
 */
function lightbox_func($atts, $content = null)
{
    $a = shortcode_atts(array('name' => 'lightbox', 'class' => 'lightbox'), $atts);
    wp_register_script('lightbox', YONK_URL . 'assets/js/lightbox.min.js', false, '2.8.2');
    wp_enqueue_script('lightbox');
    wp_register_style('lightbox', YONK_URL . 'assets/css/lightbox.min.css', false, '2.8.2', 'all');
    wp_enqueue_style('lightbox');
    if (!isset($a['post'])) {
        global $post;
        $p = $post;
    } else {
        $p = get_post(intval($a['post']));
    }
    $image_urls = explode('~~~', Yonk_Frontend::get_meta('gallery_attachments', $p));
    ob_start();
    ?>
	<div style="position:relative;">
		<div id="<?php 
    echo $a['name'];
    ?>
" class="<?php 
    echo $a['class'];
    ?>
">
<?php 
    foreach ($image_urls as $url) {
        $attachment_id = get_attachment_id($url);
        $attachment = get_post($attachment_id);
        ?>

		<a href="<?php 
        echo $url;
        ?>
" data-lightbox="<?php 
        echo $a['name'];
        ?>
" data-title="<?php 
        echo $attachment->post_excerpt;
        ?>
">
			<img src="<?php 
        echo wp_get_attachment_thumb_url($attachment_id);
        ?>
" alt="<?php 
        echo $attachment->post_title;
        ?>
" />
		</a>

		<?php 
    }
    ?>
		</div>
	</div>
<?php 
    return ob_get_clean();
}
Ejemplo n.º 7
0
function qeui_add_thumbnail_callback()
{
    $thumb_id = $_POST['thumb_id'];
    $post_id = $_POST['post_id'];
    $thumbnail = wp_get_attachment_thumb_url($thumb_id);
    update_post_meta($post_id, '_thumbnail_id', $thumb_id);
    echo json_encode(array('post_id' => $post_id, 'img_url' => $thumbnail, 'thumb_id' => $thumb_id));
    die;
}
Ejemplo n.º 8
0
 public static function getImages($brochure)
 {
     $images = array();
     foreach ($brochure['image_gallery'] as $image) {
         $row['image_url'] = wp_get_attachment_url($image);
         $row['thumbnail_url'] = wp_get_attachment_thumb_url($image);
         $row['thumbnail_image'] = wp_get_attachment_image($image);
         $images[] = $row;
     }
     return $images;
 }
Ejemplo n.º 9
0
 /**
  * Get an customer avatar
  *
  * @param  integer  avatar size in pixels
  *
  * @return string  image with HTML tag
  */
 public function get_avatar($size = 32)
 {
     if ($this->id) {
         $user_photo_id = $this->get_meta('photo_id', true);
         if (!empty($user_photo_id)) {
             $image = wp_get_attachment_thumb_url($user_photo_id);
             return sprintf('<img src="%1$s" alt="" class="avatar avatar-%2$s photo" height="auto" width="%2$s" />', $image, $size);
         }
     }
     return get_avatar($this->email, $size);
 }
Ejemplo n.º 10
0
function echo_first_image($postID)
{
    $args = array('numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $postID, 'post_status' => null, 'post_type' => 'attachment');
    $attachments = get_children($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
            $image_attributes = wp_get_attachment_image_src($attachment->ID, 'thumbnail') ? wp_get_attachment_image_src($attachment->ID, 'thumbnail') : wp_get_attachment_image_src($attachment->ID, 'full');
            echo '<img src="' . wp_get_attachment_thumb_url($attachment->ID) . '">';
        }
    }
}
Ejemplo n.º 11
0
        add_post_meta($post_ID, 'mgop_media_value', $data, true) or update_post_meta($post_ID, 'mgop_media_value', $data);
    }
    public function mb_callback($post, $box)
    {
        $value = get_post_meta($post->ID, 'mgop_media_value', true);
        $value = isset($value[$box['id']]) ? $value[$box['id']] : array();
        wp_nonce_field(plugin_basename(__FILE__), 'mgop_noncename');
        ?>
		
		<a href="#" class="mgop_add" data-for="<?php 
        echo $box['id'];
        ?>
" title="<?php 
        echo $box['title'];
        ?>
">Add Image</a>
		<ul id="mgop_<?php 
        echo $box['id'];
        ?>
" class="mgop-wrapper-sortable">
			<?php 
        if (is_array($value) && count($value)) {
            foreach ($value as $attc_id) {
                $url = wp_get_attachment_thumb_url($attc_id);
                ?>
				<li class="mgop_thumnails" title="Drag and drop to sort the item"><div><span class="mgop-movable"></span><a href="#" class="mgop_remove_item" title="Click to delete this item"><span>delete</span></a><img src="<?php 
                echo $url;
                ?>
"><input type="hidden" name="mgop_media[<?php 
                echo $box['id'];
                ?>
][]" value="<?php 
                echo $attc_id;
                ?>
" /></div></li>
			<?php 
            }
        }
        ?>
		</ul>
		<div class="mgop-detail" style="border-top: 1px solid #ccc;">
			<ul>
				<li><label>Gallery Slug</label>: <code><?php 
        echo $box['args']['slug'];
        ?>
</code></li>
				<li><label>Output Location</label>: <?php 
        echo $this->positions[$box['args']['position']];
        ?>
</li>
Ejemplo n.º 12
0
/**
 * Get an avatar avatar
 *
 * @param  integer  avatar size in pixels
 *
 * @return string  image with HTML tag
 */
function erp_crm_get_avatar($id, $size = 32, $user = false)
{
    if ($id) {
        if ($user) {
            return get_avatar($id, $size);
        }
        $user_photo_id = erp_people_get_meta($id, 'photo_id', true);
        if (!empty($user_photo_id)) {
            $image = wp_get_attachment_thumb_url($user_photo_id);
            return sprintf('<img src="%1$s" alt="" class="avatar avatar-%2$s photo" height="auto" width="%2$s" />', $image, $size);
        }
    }
    return get_avatar($id, $size);
}
function uz_ui_load_more_images()
{
    global $wpdb;
    $offset = esc_sql($_GET['offset']);
    $offset = $offset ? $offset * 25 : 0;
    $images = $wpdb->get_results(" SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date DESC LIMIT {$offset},25 ");
    foreach ($images as $key => $image) {
        $images[$key]->url = wp_get_attachment_thumb_url($image->ID);
    }
    if (count($images) > 0) {
        echo json_encode($images);
    }
    die;
}
Ejemplo n.º 14
0
function edit_automobile_category_fields($term)
{
    global $autoMobile;
    $automobile_category_extra_fields = get_option('automobile_category_images');
    $thumbnail_id = absint($automobile_category_extra_fields[$term->term_id]['automobile_category_images']);
    if ($thumbnail_id) {
        $image = wp_get_attachment_thumb_url($thumbnail_id);
    } else {
        $image = $autoMobile->auto_mobile_default_image();
    }
    ?>
		
		<tr class="form-field">
			<th scope="row" valign="top"><label><?php 
    echo _e('Thumbnail', 'automobileoptions');
    ?>
</label></th>
			<td>
				<div id="automobile_product_category_thumbnail" style="float: left; margin-right: 10px;"><img src="<?php 
    echo esc_url($image);
    ?>
" width="60px" height="60px" /></div>
				<div style="line-height: 60px;">
					<input type="hidden" id="automobile_product_category_thumbnail_id" name="automobile_product_category_thumbnail_id" value="<?php 
    echo $thumbnail_id;
    ?>
" />
					<button type="button" class="upload_image_button button"><?php 
    echo _e('Upload/Add image', 'automobileoptions');
    ?>
</button>
					<button type="button" class="remove_image_button button"><?php 
    echo _e('Remove image', 'automobileoptions');
    ?>
</button>
				</div>
<script type="text/javascript">

					// Only show the "remove image" button when needed
					if ( '0' === jQuery( '#automobile_product_category_thumbnail_id' ).val() ) {
						jQuery( '.remove_image_button' ).hide();
					}
					
				</script>				
				<div class="clear"></div>
			</td>
		</tr>
		<?php 
}
Ejemplo n.º 15
0
    /**
     * Outputs the content of the widget
     *
     * @param array $args
     * @param array $instance
     */
    public function widget($args, $instance) {
        $title = apply_filters('widget_title', $instance['title']);
        $imgWidth = apply_filters('widget_img_width', $instance['img_width']);
        $imgHight = apply_filters('widget_img_height', $instance['img_height']);
        $gallery_images = apply_filters('gallery_images', $instance['gallery_images']);
        $gallery_images = !empty($gallery_images) ? maybe_unserialize($gallery_images) : false;
        echo $args['before_widget'];

        if (!empty($title)) {
            echo $args['before_title'] . $title . $args['after_title'];
        }

        if (!empty($gallery_images)) {
            $carousel = '<div class="gallery-popup-wrap">';
            $carousel .= sprintf('<div id="gallery-%s" class="popup-gallery">', $args['widget_id']);
            foreach ($gallery_images as $attachment_id) {
                $image = wp_get_attachment_image_src($attachment_id, 'full');
                
                $thumb_url = wp_get_attachment_thumb_url($attachment_id);
                $carousel .= sprintf('<div class="gallery-item"><a href="%1$s"><img src="%2$s" alt="gallery-image" width="%3$s" height="%4$s" alt="Gallery Image"></a></div>', $image[0], $thumb_url, $imgWidth, $imgHight);
            }
            $carousel .= '</div>';
            $carousel .= '</div>';
            $nav = ($carousel_nav == 'yes') ? 'true' : 'false';
            $dot = ($carousel_dot == 'yes') ? 'true' : 'false';
            $autoplay = ($carousel_autoplay == 'yes') ? 'true' : 'false';
            $item = !empty($image_display) ? $image_display : 1;
            echo $carousel;
            ?>
            <script type="text/javascript">
                jQuery(document).ready(function () {
                    if (typeof jQuery.fn.magnificPopup !== 'undefined') {
                        jQuery('.popup-gallery').magnificPopup({
                            type: 'image',
                            delegate: 'a',
                            gallery: {
                                enabled: true
                            }
                        });
                    }
                    console.log(typeof jQuery.fn.magnificPopup);
                });
            </script>
            <?php
        }
        echo '<div class="clearfix"></div>';
        echo $args['after_widget'];
    }
Ejemplo n.º 16
0
 public function igallery_ajax_req()
 {
     $nonce = $_POST['i_nonce'];
     if (!wp_verify_nonce($nonce, 'igallery-nonce-default')) {
         die('Busted!');
     }
     $at_id = $_POST['attachementID'];
     $post_thumb = wp_get_attachment_thumb_url($at_id);
     if (!$post_thumb) {
         $post_thumb = 'http://placehold.it/150x150';
     }
     $response = json_encode(array('thumb_url' => $post_thumb));
     header("Content-Type: application/json");
     echo $response;
     exit;
 }
Ejemplo n.º 17
0
function nautilus_get_post_thumbnail($post_id)
{
    $thumb_url = wp_cache_get($post_id, 'post_thumbs');
    if (false !== $thumb_url) {
        return $thumb_url;
    } else {
        $thumb_url = '';
        $rows =& get_children("post_parent={$post_id}&post_type=attachment&numberposts=1");
        if ($rows) {
            $attachment = array_shift($rows);
            $thumb_url = wp_get_attachment_thumb_url($attachment->ID);
        }
        wp_cache_add($post_id, $thumb_url, 'post_thumbs');
        return $thumb_url;
    }
}
Ejemplo n.º 18
0
function get_cats()
{
    $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'include' => '1422, 1344, 984, 1446, 1000, 1050, 996, 975, 987, 1016, 994, 564, 1186, 1048, 654, 1135, 645, 1445'));
    $ch_n = 0;
    if ($catTerms) {
        echo '<ul class="ch-grid">';
        foreach ($catTerms as $catTerm) {
            $thumbnail_id = get_woocommerce_term_meta($catTerm->term_id, 'thumbnail_id', true);
            $image = wp_get_attachment_thumb_url($thumbnail_id);
            $ch_n++;
            echo '<li><a title="Перейти" href="/products/' . $catTerm->slug . '"><div class="ch-item" style="background-image: url(' . $image . '); background-size: 80%; background-repeat: no-repeat; background-color: white;"><div class="ch-info"><h3>' . $catTerm->name . '</h3></div></div></a></li>';
        }
        wp_reset_query();
        echo '</ul>';
    }
}
Ejemplo n.º 19
0
 function render_input($args, $images = "", $default_selected = "")
 {
     // nm_personalizedproduct_pa($images);
     $_html = '<div class="pre_upload_image_box">';
     $img_index = 0;
     $popup_width = $args['popup-width'] == '' ? 600 : $args['popup-width'];
     $popup_height = $args['popup-height'] == '' ? 450 : $args['popup-height'];
     if ($images) {
         foreach ($images as $image) {
             $_html .= '<div class="pre_upload_image">';
             if ($image['id'] != '') {
                 $_html .= '<img src="' . wp_get_attachment_thumb_url($image['id']) . '" />';
             } else {
                 $_html .= '<img width="150" height="150" src="' . $image['link'] . '" />';
             }
             // for bigger view
             $_html .= '<div style="display:none" id="pre_uploaded_image_' . $args['id'] . '-' . $img_index . '"><img style="margin: 0 auto;display: block;" src="' . $image['link'] . '" /></div>';
             $_html .= '<div class="input_image">';
             if ($args['multiple-allowed'] == 'on') {
                 $_html .= '<input type="checkbox" data-price="' . $image['price'] . '" data-title="' . stripslashes($image['title']) . '" name="' . $args['name'] . '[]" value="' . esc_attr(json_encode($image)) . '" />';
             } else {
                 //default selected
                 $checked = $image['title'] == $default_selected ? 'checked = "checked"' : '';
                 $_html .= '<input type="radio" data-price="' . $image['price'] . '" data-title="' . stripslashes($image['title']) . '" data-type="' . stripslashes($args['data-type']) . '" name="' . $args['name'] . '" value="' . esc_attr(json_encode($image)) . '" ' . $checked . ' />';
             }
             $price = '';
             if (function_exists('woocommerce_price') && $image['price'] > 0) {
                 $price = woocommerce_price($image['price']);
             }
             // image big view
             $_html .= '<a href="#TB_inline?width=' . $popup_width . '&height=' . $popup_height . '&inlineId=pre_uploaded_image_' . $args['id'] . '-' . $img_index . '" class="thickbox" title="' . $image['title'] . '"><img width="15" src="' . $this->plugin_meta['url'] . '/images/zoom.png" /></a>';
             $_html .= '<div class="p_u_i_name">' . stripslashes($image['title']) . ' ' . $price . '</div>';
             $_html .= '</div>';
             //input_image
             $_html .= '</div>';
             $img_index++;
         }
     }
     $_html .= '<div style="clear:both"></div>';
     //container_buttons
     $_html .= '</div>';
     //container_buttons
     echo $_html;
     $this->get_input_js($args);
 }
 static function get_photo_details($image_id)
 {
     $image_info_array = array();
     $thumb_url = wp_get_attachment_thumb_url($image_id);
     $attachment_img = wp_get_attachment_image($image_id);
     $alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
     $image_post = get_post($image_id);
     $image_desc = $image_post->post_content;
     $upload_date = $image_post->post_date;
     $galley_id = get_post_meta($image_id, '_wppg_gallery_id', true);
     //if the alt text meta is blank, let's set it to the image name
     if ($alt_text == '' || $alt_text == NULL) {
         $alt_text = $image_post->post_name;
     }
     $image_info = array('id' => $image_id, 'gallery_id' => $galley_id, 'thumb_url' => $thumb_url, 'alt_text' => $alt_text, 'description' => $image_desc, 'date_uploaded' => $upload_date);
     $image_info_array = $image_info;
     return $image_info_array;
 }
Ejemplo n.º 21
0
 private function get_testimonials($intro)
 {
     $args = array("post_type" => "testimonial", "orderby" => "post_date", "order" => "DESC");
     $query = array_merge($args, $intro->get_paging_query());
     $posts = query_posts($query);
     $output = array();
     while (have_posts()) {
         the_post();
         global $post;
         $output = new JSON_API_Post($post);
         $feature = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));
         $link = get_post_meta($post->ID, "_website", true);
         $output->feature = $feature ? "<div class=\"img\" style=\"background: url('{$feature}') no-repeat center center; background-size: cover; min-height: 150px;\"></div>" : "<div src=\"" . get_template_directory_uri() . "/library/img/default.jpg\" class=\"no-image\" ></div>";
         $output->link = empty($link) ? "" : "<a class=\"float-right\" href=\"" . $link . "\" target=\"_blank\">Visit site...</a></p>";
         $output->owner = get_post_meta($post->ID, "_sub_title", true);
         array_push($this->testimonials, $output);
     }
     wp_reset_postdata();
 }
Ejemplo n.º 22
0
function ls_get_thumbnail($id = null, $url = null)
{
    // Image ID
    if (!empty($id)) {
        if ($image = wp_get_attachment_thumb_url($id, 'thumbnail')) {
            return $image;
        }
    }
    if (!empty($url)) {
        $thumb = substr_replace($url, '-150x150.', strrpos($url, '.'), 1);
        $file = LS_ROOT_PATH . '/sampleslider/' . basename($thumb);
        if (file_exists($file)) {
            return $thumb;
        } else {
            return $url;
        }
    }
    return LS_ROOT_URL . '/static/img/not_set.png';
}
Ejemplo n.º 23
0
 /**
  * Rebuild the given attribute with the given thumbnails
  *
  * @param $att_id
  * @param $thumbnails
  *
  * @return array
  * @author Nicolas Juen
  */
 public static function thumbnail_rebuild($att_id, $thumbnails = null)
 {
     // Time a the begining
     timer_start();
     // Check Id
     if ((int) $att_id <= 0) {
         return array('time' => timer_stop(false, 4), 'error' => __('No id given in POST datas.', 'simple-image-sizes'));
     }
     // Get the path
     $fullsizepath = get_attached_file($att_id);
     // Regen the attachment
     if (false !== $fullsizepath && file_exists($fullsizepath)) {
         if (false == wp_update_attachment_metadata($att_id, self::wp_generate_attachment_metadata_custom($att_id, $fullsizepath, $thumbnails))) {
             return array('src' => wp_get_attachment_thumb_url($att_id), 'time' => timer_stop(false, 4), 'message' => sprintf(__('This file already exists in this size and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'simple-image-sizes'), get_edit_post_link($att_id), get_the_title($att_id)));
         }
     } else {
         return array('src' => wp_get_attachment_thumb_url($att_id), 'time' => timer_stop(false, 4), 'error' => sprintf(__('This file does not exists and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'simple-image-sizes'), get_edit_post_link($att_id), get_the_title($att_id)));
     }
     // Display the attachment url for feedback
     return array('time' => timer_stop(false, 4), 'src' => wp_get_attachment_thumb_url($att_id), 'title' => get_the_title($att_id));
 }
Ejemplo n.º 24
0
 function test_valid_media_item()
 {
     $this->make_user_by_role('author');
     $fields = array('post');
     $result = $this->myxmlrpcserver->wp_getMediaItem(array(1, 'author', 'author', $this->attachment_id, $fields));
     $this->assertNotInstanceOf('IXR_Error', $result);
     // Check data types
     $this->assertInternalType('string', $result['attachment_id']);
     $this->assertInternalType('int', $result['parent']);
     $this->assertInternalType('string', $result['title']);
     $this->assertInstanceOf('IXR_Date', $result['date_created_gmt']);
     $this->assertInternalType('string', $result['caption']);
     $this->assertInternalType('string', $result['description']);
     $this->assertInternalType('string', $result['link']);
     $this->assertInternalType('string', $result['thumbnail']);
     $this->assertInternalType('array', $result['metadata']);
     // Check expected values
     $this->assertStringMatchesFormat('%d', $result['attachment_id']);
     $this->assertEquals($this->attachment_data['post_title'], $result['title']);
     $this->assertEquals(wp_get_attachment_url($this->attachment_id), $result['link']);
     $this->assertEquals(wp_get_attachment_thumb_url($this->attachment_id), $result['thumbnail']);
 }
Ejemplo n.º 25
0
 /**
  * Get the field's HTML markup
  *
  * @param mixed The field's current value (if it exists)
  * @param array The HTML attributes to be added on the field
  *
  * @return string The field's HTML markup
  */
 public function get_the_field($value, $attributes = array())
 {
     $o = '<div id="' . $this->get_the_ID() . '"' . Youxi_Form::render_attr($attributes) . '>';
     $o .= '<div class="youxi-gallery-previews">';
     foreach ((array) $value as $val) {
         $url = wp_get_attachment_thumb_url($val);
         if (!isset($url) || empty($url)) {
             continue;
         }
         $o .= '<div class="youxi-gallery-preview-item">';
         $o .= '<div class="youxi-gallery-preview-img-wrap">';
         $o .= '<div class="youxi-gallery-preview-img-wrap-inner">';
         $o .= '<img src="' . esc_url($url) . '" alt="">';
         $o .= '</div>';
         $o .= '</div>';
         $o .= '<input type="hidden" name="' . $this->get_the_name() . '[]" class="youxi-gallery-value" value="' . esc_attr($val) . '">';
         $o .= '</div>';
     }
     $o .= '</div>';
     $o .= '</div>';
     return $o;
 }
Ejemplo n.º 26
0
    /**
     * Copy product Category Custom fields
     *
     * Copy the category custom fields from orginal category to its translations
     * when we start adding new category translation
     *
     * @return boolean false if this action must not be executed
     */
    public function copyProductCatCustomFields()
    {
        /* We sync custom fields only for translation */
        if (!(isset($_GET['from_tag']) && isset($_GET['new_lang']))) {
            return false;
        }
        $ID = esc_attr($_GET['from_tag']);
        $type = get_woocommerce_term_meta($ID, 'display_type', true);
        $thumbID = absint(get_woocommerce_term_meta($ID, 'thumbnail_id', true));
        $image = $thumbID ? wp_get_attachment_thumb_url($thumbID) : wc_placeholder_img_src();
        ?>
        <script type="text/javascript">
            jQuery('document').ready(function ($) {
                $('#display_type option[value="<?php 
        echo $type;
        ?>
"]')
                        .attr("selected", true);
                $('#product_cat_thumbnail img').attr('src', '<?php 
        echo $image;
        ?>
');
                $('#product_cat_thumbnail_id').val('<?php 
        echo $thumbID;
        ?>
');
        <?php 
        if ($thumbID) {
            ?>
                    $('.remove_image_button').show();
        <?php 
        }
        ?>
            });
        </script>
        <?php 
        /* Allow other plugins to check for category custom fields */
        do_action(HooksInterface::PRODUCT_COPY_CATEGORY_CUSTOM_FIELDS, $ID);
    }
Ejemplo n.º 27
0
    function media()
    {
        global $wpdb;
        $data = $wpdb->get_results("select post_id from " . $wpdb->prefix . "postmeta where meta_key = 'courseID' and meta_value = '" . $_GET['course_id'] . "'");
        $course_post = get_post($data[0]->post_id);
        ?>
<h2><?php 
        echo __("Media used in");
        ?>
 <?php 
        echo $course_post->post_title;
        ?>
</h2><?php 
        ?>
<p><?php 
        echo __("Click on a file to see more");
        ?>
</p><?php 
        $args = array('post_type' => 'attachment', 'post_status' => 'inherit', 'posts_per_page' => -1, 'meta_key' => 'CanvasCourse', 'meta_value' => get_post_meta($_GET['course_id'], "courseID", true), 'meta_compare' => '=');
        $query = new WP_Query($args);
        while ($query->have_posts()) {
            $query->the_post();
            $upload_url = admin_url("upload.php?item=" . get_the_id());
            ?>
<div class="media"><a href="<?php 
            echo $upload_url;
            ?>
"><p><img src="<?php 
            echo wp_get_attachment_thumb_url(get_the_ID());
            ?>
"/></p><p><?php 
            echo the_title();
            ?>
</p></a></div><?php 
        }
    }
Ejemplo n.º 28
0
/**
 * Image gallery functions
 */
function cc_gallery_images($post)
{
    $list_images = cc_list_product_image_slots();
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_enqueue_script('quicktags');
    wp_enqueue_script('jquery-ui-resizable');
    wp_enqueue_script('jquery-ui-draggable');
    wp_enqueue_script('jquery-ui-button');
    wp_enqueue_script('jquery-ui-position');
    wp_enqueue_script('jquery-ui-dialog');
    wp_enqueue_script('wpdialogs');
    wp_enqueue_script('wplink');
    wp_enqueue_script('wpdialogs-popup');
    wp_enqueue_script('wp-fullscreen');
    wp_enqueue_script('editor');
    wp_enqueue_script('word-count');
    wp_enqueue_script('img-mb', CC_URL . 'resources/js/get-images.js', array('jquery', 'media-upload', 'thickbox', 'set-post-thumbnail'));
    wp_enqueue_style('thickbox');
    wp_nonce_field('cc-gallery-images-save_' . $post->ID, 'cc-gallery-images-nonce');
    echo '<div id="droppable">';
    $z = 1;
    foreach ($list_images as $k => $i) {
        $meta = get_post_meta($post->ID, $i, true);
        $img = isset($meta) ? '<img src="' . wp_get_attachment_thumb_url($meta) . '" width="100" height="100" alt="" draggable="false">' : '';
        echo '<div class="image-entry" draggable="true">';
        echo '<input type="hidden" name="' . $k . '" id="' . $k . '" class="id_img" data-num="' . $z . '" value="' . $meta . '">';
        echo '<div class="img-preview" data-num="' . $z . '">' . $img . '</div>';
        echo '<a href="javascript:void(0);" class="get-image button-secondary" data-num="' . $z . '">' . _x('Add New', 'file') . '</a><a href="javascript:void(0);" class="del-image button-secondary" data-num="' . $z . '">' . __('Delete') . '</a>';
        echo '</div>';
        $z++;
    }
    echo '</div>';
    $page = CC_View::get(CC_PATH . 'views/admin/html-image-meta-box.php');
    echo $page;
}
Ejemplo n.º 29
0
		// loop a set of fields
		while($pages_mb->have_fields('slides')) {
			$imgID = $pages_mb->get_the_value('imgurl');
			if (is_numeric($imgID)) {
				$image_attributes = wp_get_attachment_image_src( $imgID, 'full' );
				$image_attributes = $image_attributes[0];
			} else $image_attributes = $imgID;
			$caption = $pages_mb->get_the_value('caption');
			if (isset($pages_mb->meta['slides'][$counter]['video'])) $provider = (find_oembed($pages_mb->meta['slides'][$counter]['video']));
			else $provider = '';

			if(strpos(trim($provider), ' ') !== false) $provider = 'unknown';

			$alt = ($pages_mb->get_the_value('alt')) ? $pages_mb->get_the_value('alt') : basename($image_attributes);

			if ($slider) echo '<li data-thumb="'.wp_get_attachment_thumb_url( $imgID).'">';
			if ($pages_mb->get_the_value('link')) { ?>

				<a href="<?php echo $pages_mb->get_the_value('link'); ?>" class="video">

			<?php }
			if ($pages_mb->get_the_value('video')) {
				if ($imgID && ($provider == 'Vimeo' || $provider == 'Youtube')) { ?>
				<a href="<?php $pages_mb->the_value('video'); ?>" class="fresco video <?php if (!$slider || ($slider && $counter == 0)) echo 'progressive'; ?>" data-fresco-group='<?php echo( basename(get_permalink()) ); ?>'><img alt="<?php echo $alt; ?>" src="<?php echo $image_attributes; ?>" /><div class="video"></div></a>

			<?php } else { ?>
			<div class="media <?php if ($provider == 'Twitter') echo 'tweet'; else echo strtolower($provider); ?>"><?php
				$source = $pages_mb->get_the_value('video');
				$embed_code = wp_oembed_get($source);

				if ($embed_code) echo $embed_code;
Ejemplo n.º 30
0
/**
 * Retrieve icon URL and Path.
 *
 * @since 2.1.0
 * @deprecated 2.5.0
 * @deprecated Use wp_get_attachment_image_src()
 * @see wp_get_attachment_image_src()
 *
 * @param int $id Optional. Post ID.
 * @param bool $fullsize Optional, default to false. Whether to have full image.
 * @return array Icon URL and full path to file, respectively.
 */
function get_attachment_icon_src($id = 0, $fullsize = false)
{
    _deprecated_function(__FUNCTION__, '2.5', 'wp_get_attachment_image_src()');
    $id = (int) $id;
    if (!($post = get_post($id))) {
        return false;
    }
    $file = get_attached_file($post->ID);
    if (!$fullsize && ($src = wp_get_attachment_thumb_url($post->ID))) {
        // We have a thumbnail desired, specified and existing
        $src_file = basename($src);
        $class = 'attachmentthumb';
    } elseif (wp_attachment_is_image($post->ID)) {
        // We have an image without a thumbnail
        $src = wp_get_attachment_url($post->ID);
        $src_file =& $file;
        $class = 'attachmentimage';
    } elseif ($src = wp_mime_type_icon($post->ID)) {
        // No thumb, no image. We'll look for a mime-related icon instead.
        $icon_dir = apply_filters('icon_dir', get_template_directory() . '/images');
        $src_file = $icon_dir . '/' . basename($src);
    }
    if (!isset($src) || !$src) {
        return false;
    }
    return array($src, $src_file);
}