public function sliderthumb_get()
 {
     if (isset($_POST['wpzoom_sliderthumb_embedcode']) && isset($_POST['wpzoom_sliderthumb_postid'])) {
         $url = WPZOOM_Video_API::extract_url_from_embed(trim(stripslashes($_POST['wpzoom_sliderthumb_embedcode'])));
         $postid = intval($_POST['wpzoom_sliderthumb_postid']);
         if (empty($url) || filter_var($url, FILTER_VALIDATE_URL) === false || $postid < 1) {
             wp_send_json_error();
         }
         $thumb_url = WPZOOM_Video_Thumb::fetch_video_thumbnail($url, $postid);
         header('Content-type: application/json');
         if ($thumb_url === false) {
             wp_send_json_error();
         } else {
             wp_send_json_success($thumb_url);
         }
     }
 }
Beispiel #2
0
    add_image_size('loop', option::get('thumb_width'), option::get('thumb_height'), true);
}
/* CSS file for responsive design
==================================== */
function responsive_styles()
{
    wp_enqueue_style('media-queries', get_template_directory_uri() . '/media-queries.css', array());
}
add_action('wp_enqueue_scripts', 'responsive_styles');
/* Register Video Post Format
==================================== */
add_theme_support('post-formats', array('video'));
/* Video auto-thumbnail
==================================== */
if (is_admin()) {
    WPZOOM_Video_Thumb::init();
}
/* 	Register Custom Menu
==================================== */
register_nav_menu('secondary', 'Top Menu');
register_nav_menu('primary', 'Main Menu');
/* Add support for Custom Background
==================================== */
add_theme_support('custom-background');
/* Replaces the excerpt "more" text by a link
=========================================== */
function new_excerpt_more($more)
{
    global $post;
    return '<a class="more-link" href="' . get_permalink($post->ID) . '">[' . __('Read More', 'wpzoom') . '...]</a>';
}
Beispiel #3
0
/**
 * The main image function for displaying an image.  It supports several arguments that allow developers to
 * customize how the script outputs the image.
 *
 * The image check order is important to note here.  If an image is found by any specific check, the script
 * will no longer look for images.  The check order is 'meta_key', 'the_post_thumbnail', 'attachment',
 * 'image_scan', 'callback', and 'default_image'.
 *
 * @since 0.1.0
 * @access public
 * @global $post The current post's database object.
 * @param array $args Arguments for how to load and display the image.
 * @return string|array The HTML for the image. | Image attributes in an array.
 */
function get_the_image($args = array())
{
    /* Set the default arguments. */
    $defaults = array('meta_key' => array('Thumbnail', 'thumbnail'), 'post_id' => get_the_ID(), 'attachment' => false, 'the_post_thumbnail' => true, 'size' => 'large', 'default_image' => false, 'order_of_image' => 1, 'link_to_post' => true, 'image_class' => false, 'image_scan' => true, 'width' => false, 'height' => false, 'format' => 'img', 'meta_key_save' => false, 'thumbnail_id_save' => false, 'callback' => null, 'cache' => false, 'before' => '', 'after' => '', 'echo' => true, 'custom_key' => null, 'default_size' => null);
    /* Allow plugins/themes to filter the arguments. */
    $args = apply_filters('get_the_image_args', $args);
    /* Merge the input arguments and the defaults. */
    $args = wp_parse_args($args, $defaults);
    /* If $default_size is given, overwrite $size. */
    if (!is_null($args['default_size'])) {
        $args['size'] = $args['default_size'];
    }
    // Deprecated 0.5 in favor of $size
    /* If $custom_key is set, overwrite $meta_key. */
    if (!is_null($args['custom_key'])) {
        $args['meta_key'] = $args['custom_key'];
    }
    // Deprecated 0.6 in favor of $meta_key
    /* If $format is set to 'array', don't link to the post. */
    if ('array' == $args['format']) {
        $args['link_to_post'] = false;
    }
    /* Extract the array to allow easy use of variables. */
    extract($args);
    /* Get cache key based on $args. */
    $key = md5(serialize(compact(array_keys($args))));
    /* Check for a cached image. */
    $image_cache = wp_cache_get($post_id, 'get_the_image');
    if (!is_array($image_cache)) {
        $image_cache = array();
    }
    /* Set up a default, empty $image_html variable. */
    $image_html = '';
    /* If there is no cached image, let's see if one exists. */
    if (!isset($image_cache[$key]) || empty($cache)) {
        /* If a custom field key (array) is defined, check for images by custom field. */
        if (!empty($meta_key)) {
            $image = get_the_image_by_meta_key($args);
        }
        /* If no image found and $the_post_thumbnail is set to true, check for a post image (WP feature). */
        if (empty($image) && !empty($the_post_thumbnail)) {
            $image = get_the_image_by_post_thumbnail($args);
            if (!isset($image['src'])) {
                unset($image);
            }
        }
        /* If no image found and $attachment is set to true, check for an image by attachment. */
        if (empty($image) && !empty($attachment)) {
            $image = get_the_image_by_attachment($args);
        }
        /* If no image found, try using the video thumbnail if the post contains a video in the embed field. (WPZOOM customization) */
        if (empty($image)) {
            if (!class_exists('WPZOOM_Video_Thumb')) {
                require_once WPZOOM_INC . '/components/video-thumb.php';
            }
            $wpzthumburl = WPZOOM_Video_Thumb::gettheimage_url($post_id);
            if ($wpzthumburl !== false) {
                $image = $wpzthumburl;
            }
        }
        /* If no image found and $image_scan is set to true, scan the post for images. */
        if (empty($image) && !empty($image_scan)) {
            $image = get_the_image_by_scan($args);
        }
        /* If no image found and a callback function was given. Callback function must pass back array of <img> attributes. */
        if (empty($image) && !is_null($callback) && function_exists($callback)) {
            $image = call_user_func($callback, $args);
        }
        /* If no image found and a $default_image is set, get the default image. */
        if (empty($image) && !empty($default_image)) {
            $image = get_the_image_by_default($args);
        }
        /* If an image was found. */
        if (!empty($image)) {
            /* If $meta_key_save was set, save the image to a custom field. */
            if (!empty($meta_key_save)) {
                get_the_image_meta_key_save($args, $image['src']);
            }
            /* Format the image HTML. */
            $image_html = get_the_image_format($args, $image);
            /* Set the image cache for the specific post. */
            $image_cache[$key] = $image_html;
            wp_cache_set($post_id, $image_cache, 'get_the_image');
        }
    } else {
        $image_html = $image_cache[$key];
    }
    /* Allow plugins/theme to override the final output. */
    $image_html = apply_filters('get_the_image', $image_html);
    /* If $format is set to 'array', return an array of image attributes. */
    if ('array' == $format) {
        /* Set up a default empty array. */
        $out = array();
        /* Get the image attributes. */
        $atts = wp_kses_hair($image_html, array('http'));
        /* Loop through the image attributes and add them in key/value pairs for the return array. */
        foreach ($atts as $att) {
            $out[$att['name']] = $att['value'];
        }
        if (isset($out['src'])) {
            $out['url'] = $out['src'];
            // @deprecated 0.5 Use 'src' instead of 'url'.
        }
        /* Return the array of attributes. */
        return $out;
    } elseif (false === $echo) {
        return $args['before'] . $image_html . $args['after'];
    }
    /* If there is a $post_thumbnail_id, do the actions associated with get_the_post_thumbnail(). */
    if (isset($image['post_thumbnail_id'])) {
        do_action('begin_fetch_post_thumbnail_html', $post_id, $image['post_thumbnail_id'], $size);
    }
    /* Display the image if we get to this point. */
    if ($image_html) {
        echo $args['before'] . $image_html . $args['after'];
    }
    /* If there is a $post_thumbnail_id, do the actions associated with get_the_post_thumbnail(). */
    if (isset($image['post_thumbnail_id'])) {
        do_action('end_fetch_post_thumbnail_html', $post_id, $image['post_thumbnail_id'], $size);
    }
}