?> " src="<?php if (class_exists('MultiPostThumbnails')) { echo MultiPostThumbnails::get_post_thumbnail_url('project', 'foreground-rollover-image', get_post_meta($module->ID, 'module_id', true), $display_size); } ?> " /></div><?php } if (get_post_meta($module->ID, 'module_size', true) == 'dual-small' || get_post_meta($module->ID, 'module_size', true) == 'dual-medium' || get_post_meta($module->ID, 'module_size', true) == 'dual-large') { ?> <div class="module-background-image"><img id="background-image-<?php echo get_post_meta($module->ID, 'module_id', true); ?> " src="<?php if (class_exists('MultiPostThumbnails')) { echo MultiPostThumbnails::get_post_thumbnail_url('project', 'background-rollover-image', get_post_meta($module->ID, 'module_id', true), $display_size); } ?> " /></div><?php } if ($block_link) { ?> </a><?php } ?> </div>'); <?php } } ?> </script>
public function get_image_url($type, $post_id, $size = null) { if (class_exists('MultiPostThumbnails')) { return \MultiPostThumbnails::get_post_thumbnail_url($this->id, $type, $post_id, $size); } return null; }
/** * Retrieve the source of an image added through multiple post thumbnails. * * @param string $type Type of thumbnail being requested. * @param string $size Size of thumbnail being requested. * * @return bool|string URL of the image if available. False if not. */ public function get_thumbnail_image_src($type, $size = null) { if (class_exists('MultiPostThumbnails')) { return MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), $type, get_the_ID(), $size); } return false; }
</a> </div> <div class="col-md-2 modal-thumb-web"> <a href="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'seventh-image', NULL, 'secondary-featured-thumbnail'); ?> " data-lightbox="third-image"> <div class="modal-thumb-overlay transition-fast"></div> <img width="100%" src="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'seventh-image', NULL, 'secondary-featured-thumbnail'); ?> "/> </a> </div> <div class="col-md-2 modal-thumb-web"> <a href="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'eighth-image', NULL, 'secondary-featured-thumbnail'); ?> " data-lightbox="third-image"> <div class="modal-thumb-overlay transition-fast"></div> <img width="100%" src="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'eighth-image', NULL, 'secondary-featured-thumbnail'); ?> "/> </a> </div> </div> </div> <div class="modal-bg"></div> </div>
<?php } ?> <?php if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'image3')) { ?> <?php $post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id(get_post_type(), 'image3', get_queried_object_id()); $post_thumbnail_post = get_post($post_thumbnail_id); $caption = trim(strip_tags($post_thumbnail_post->post_excerpt)); $caption = esc_html($caption); ?> <figure class="extra-image"> <img src="<?php echo $imgURL = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'image3', NULL, 'large'); ?> " alt="<?php echo $caption; ?> " /> <figcaption><?php echo $caption; ?> </figcaption> </figure> <?php } ?> </div>
<?php // https://github.com/voceconnect/multi-post-thumbnails/wiki // Image settings $post_image_before = ''; $post_image_after = ''; $img_url = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image', null, 'full'); //get img URL $img_width = '250'; $img_height = '71'; $figure_class = 'business-logo'; $img_attr = of_get_option('load_image') == 'false' || of_get_option('load_image') == "" ? 'src="' : 'src="//" data-src="'; // Resize & crop img $image = $img_attr . aq_resize($img_url, $img_width, $img_height, true) . '"'; // Image markup echo '<figure class="' . $figure_class . '">' . $post_image_before . '<img ' . $image . ' alt="' . get_the_title() . '" >' . $post_image_after . '</figure>';
?> </div> <!-- /.navbar-collapse --> </div> <!-- /.container --> </nav> <?php ?> <!-- Page Header --> <!-- Set your background image for this header on the line below. --> <header class="intro-header" style="background-image: url('<?php //Get the Thumbnail URL $success = false; if (class_exists('MultiPostThumbnails')) { $src = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'page-header', $post->ID); if ($src != '') { $success = true; echo $src; } else { $success = false; } } if (has_post_thumbnail() && $success == false) { $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(1900, 600), false, ''); $data = getimagesize($src[0]); $width = $data[0]; $height = $data[1]; if ($width > 1000 && $height > 500) { $success = true; echo $src[0];
function kite_get_secondary_background_image($default) { if (class_exists('MultiPostThumbnails')) { if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'background-image')) { return MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'background-image'); } else { return $default; } } else { return $default; } }
/** * Generate posts array * * @param $posts * @param $offset * @param $taxonomy * @param $eager_loading * @param $post_type * @param $final_posts * * @return mixed */ function get_final_posts($posts, $offset, $taxonomy, $eager_loading, $final_posts) { foreach ($posts as $post) { $final_post = array(); $post_id = $post->ID; $key = http_build_query(array('post_id' => "{$post_id}", "type" => "ml_post")); $cache = get_cache('ml_post', $key); if (!empty($cache)) { $final_posts["posts"][] = unserialize($cache); continue; } $final_post["post_id"] = "{$post_id}"; $final_post["post_type"] = $post->post_type; $final_post["author"] = array(); $final_post["categories"] = array(); $final_post["author"]["name"] = html_entity_decode(get_author_name($post->post_author)); $final_post["author"]["author_id"] = $post->post_author; $final_post["title"] = strip_tags($post->post_title); $final_post["title"] = html_entity_decode($final_post["title"], ENT_QUOTES); $final_post["videos"] = array(); $final_post["images"] = array(); if ($offset > 0 && is_sticky($post_id)) { continue; } /** comments ======================================================================== **/ $images = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image')); $comments_count = wp_count_comments($post_id); $final_post["comments-count"] = 0; if ($comments_count) { $final_post["comments-count"] = intval($comments_count->approved); } /** permalink ======================================================================== **/ $final_post["permalink"] = get_permalink($post_id); if (strlen(trim(get_option('ml_custom_field_url', ''))) > 0) { $custom_url_value = get_post_meta($post->ID, get_option('ml_custom_field_url'), true); if (strlen(trim($custom_url_value)) > 0) { $final_post["permalink"] = $custom_url_value; } } /** categories ======================================================================== **/ $categories = get_the_category($post_id); foreach ($categories as $category) { $final_post["categories"][] = array("cat_id" => "{$category->cat_ID}", "name" => $category->cat_name, "slug" => $category->category_nicename); } if ($taxonomy !== 'category' && !empty($taxonomy)) { $terms = wp_get_post_terms($post_id, $taxonomy); foreach ($terms as $term) { $final_post["categories"][] = array("cat_id" => "{$term->term_id}", "name" => $term->name, "slug" => $term->slug); } } /** date ======================================================================== **/ $final_post["date"] = $post->post_date; if (get_option('ml_datetype', 'prettydate') == 'datetime') { $final_post["date_display"] = date_i18n(get_option('ml_dateformat', 'F j, Y'), strtotime($post->post_date), get_option('gmt_offset')); } /** media ======================================================================== **/ try { $video_id = get_the_first_youtube_id($post); } catch (Exception $e) { } try { //featured image $main_image_url = get_the_first_image($post); } catch (Exception $e) { //error getting or resizing the images } if ($video_id != null) { $final_post["videos"][] = $video_id; } if ($main_image_url != null) { $image = array("full" => $main_image_url, "thumb" => array("url" => $main_image_url), "big-thumb" => array("url" => $main_image_url)); $final_post["images"][0] = $image; } if (strlen(get_option('ml_custom_featured_image')) > 0 && class_exists('MultiPostThumbnails')) { $customImageUrl = MultiPostThumbnails::get_post_thumbnail_url(get_post_type($post->ID), Mobiloud::get_option('ml_custom_featured_image'), $post->ID, 'large'); if ($customImageUrl !== false) { $final_post["images"][0] = array("full" => $customImageUrl, "thumb" => array("url" => $customImageUrl), "big-thumb" => array("url" => $customImageUrl)); } } foreach ((array) $images as $image) { $imageToAdd = array(); $imageToAdd["full"] = wp_get_attachment_image_src($image->ID, 'full'); $imageToAdd["thumb"] = wp_get_attachment_image_src($image->ID, 'thumbnail'); $imageToAdd["imageId"] = $image->ID; $final_post["images"][] = $imageToAdd; } /** Content ======================================================================== **/ //capturing the html output generated ob_start(); include "post/post.php"; $html_content = ob_get_clean(); //replace relative URLs with absolute $html_content = preg_replace("#(<\\s*a\\s+[^>]*href\\s*=\\s*[\"'])(?!http|/)([^\"'>]+)([\"'>]+)#", '$1' . $final_post["permalink"] . '/$2$3', $html_content); $final_post["content"] = $html_content; /** Sticky ======================================================================== **/ //sticky ? $final_post["sticky"] = is_sticky($post->ID) || $post->sticky; /** Custom field ======================================================================== **/ if (strlen(get_option('ml_custom_field_name', '')) > 0) { if (get_option('ml_custom_field_name', '') == "excerpt") { $custom_field_val = html_entity_decode(urldecode(strip_tags(get_post_excerpt($post->ID)))); $final_post['custom1'] = $custom_field_val; } else { $custom_field_val = get_post_meta($post->ID, get_option('ml_custom_field_name', ''), true); $final_post['custom1'] = $custom_field_val; } } //excerpt $final_post['excerpt'] = html_entity_decode(urldecode(strip_tags(get_post_excerpt($post->ID)))); $final_post['excerpt'] = str_replace('Read More', '', $final_post['excerpt']); if (get_post_format($post) == 'status') { $final_post["title"] = $post->post_content; $final_post["content"] = ""; $final_post['custom1'] = ""; $final_post['excerpt'] = ""; } set_cache('ml_post', $key, serialize($final_post)); $final_posts["posts"][] = $final_post; } return $final_posts; }
$link_to = get_post_meta($post->ID, 'external_link', true) ? get_post_meta($post->ID, 'external_link', true) : get_permalink($post->ID); } $display_size; if ($GLOBALS['device_type'] == 'mobile') { $display_size = 'small'; } else { $display_size = 'small'; } $off_image = false; $off_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'xsmall'); $off_image_large = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), $display_size); if ($off_image) { $images_script .= '"off-image-' . $post->ID . '":"' . $off_image_large[0] . '", '; } $over_image = false; $over_image = MultiPostThumbnails::get_post_thumbnail_url('post', 'rollover-image', $post->ID, $display_size); if ($over_image) { $preload_script .= "'" . $over_image . "',"; //$images_script .= '"over-image-' . $post->ID . '":"' . $over_image . '", '; } ?> <div class="grid-element <?php echo rtrim($term_class, ' '); ?> "> <?php if ($link_to) { ?> <a href="<?php echo $link_to; ?>
<?php /*-----------------------------------------------------------------------------------*/ /* Display featured portfolio project /*-----------------------------------------------------------------------------------*/ $args = array('posts_per_page' => 1, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'ca_portfolio', 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'ca_categories', 'field' => 'slug', 'terms' => 'featured'))); $projects = get_posts($args); for ($i = 0; $i < count($projects); $i++) { $project_id = $projects[$i]->ID; $projectName = get_the_title($project_id); $projectExcerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $project_id)); // Get the featured image to display on the card if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('ca_portfolio', 'homepage-feature-image', $project_id)) { $projectImage = MultiPostThumbnails::get_post_thumbnail_url('ca_portfolio', 'homepage-feature-image', $project_id); } ?> <div class="grid__half"> <h3 class="h2"><?php echo $projectName; ?> </h3> <?php echo $projectExcerpt; ?> <?php echo do_shortcode('[button link="' . get_the_permalink($project_id) . '"]View Project[/button]'); ?> </div> <div class="grid__half"> <img src="<?php echo $projectImage;
<section class="hero <?php echo is_page('writings') || is_page('showcase') ? 'hero--small' : ''; ?> "> <?php if (is_front_page()) { echo '<div class="hero__gradient"></div>'; } $postType = get_post_type($id); if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail($postType, 'hero-image', $id) && !is_archive()) { $hero = MultiPostThumbnails::get_post_thumbnail_url($postType, 'hero-image', $id); if (MultiPostThumbnails::has_post_thumbnail($postType, 'mobile-hero-image', $id)) { $mobileHero = MultiPostThumbnails::get_post_thumbnail_url($postType, 'mobile-hero-image', $id); } if (MultiPostThumbnails::has_post_thumbnail($postType, 'medium-hero-image', $id)) { $mediumHero = MultiPostThumbnails::get_post_thumbnail_url($postType, 'medium-hero-image', $id); } ?> <picture> <source media="(min-width: 80em)" srcset="<?php echo $hero; ?> "> <source media="(min-width: 64em)" srcset="<?php echo $mediumHero; ?> "> <source media="(max-width: 64em)" srcset="<?php echo $mobileHero; ?> ">
/** * Renders card meta fields in wp_head * @return string */ static function render_card_meta() { if (!is_singular(array_keys(self::$post_types))) { return; } $vpm_group = get_post_type() . '_twitter_card'; if (!($card_type = get_vpm_value($vpm_group, 'twitter_card_type', get_queried_object_id()))) { return; } $card_data = array('card' => $card_type, 'title' => self::get_the_title(), 'description' => self::get_the_description()); switch ($card_type) { case 'gallery': $images = array(); for ($i = 1; $i <= 4; $i++) { if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'twitter-card-gallery-image-' . $i, get_queried_object_id())) { $images['image' . ($i - 1)] = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'twitter-card-gallery-image-' . $i, get_queried_object_id(), 'medium'); } } if (!empty($images)) { $card_data = array_merge($card_data, $images); } break; case 'summary_large_image': if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'twitter-card-large-image', get_queried_object_id())) { $card_data['image'] = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'twitter-card-large-image', get_queried_object_id(), 'large'); } break; case 'product': if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'twitter-card-product-image', get_queried_object_id())) { $card_data['image'] = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'twitter-card-product-image', get_queried_object_id(), 'large'); } $card_data['data1'] = get_vpm_value($vpm_group, 'twitter_card_data1', get_queried_object_id()); $card_data['label1'] = get_vpm_value($vpm_group, 'twitter_card_label1', get_queried_object_id()); $card_data['data2'] = get_vpm_value($vpm_group, 'twitter_card_data2', get_queried_object_id()); $card_data['label2'] = get_vpm_value($vpm_group, 'twitter_card_label2', get_queried_object_id()); break; case 'photo': case 'summary': if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium'); if ($image) { $card_data['image'] = $image[0]; } } break; case 'player': $card_data['player'] = get_vpm_value($vpm_group, 'twitter_card_player_url', get_queried_object_id()); $card_data['player:width'] = get_vpm_value($vpm_group, 'twitter_card_player_width', get_queried_object_id()); $card_data['player:height'] = get_vpm_value($vpm_group, 'twitter_card_player_height', get_queried_object_id()); $card_data['image'] = get_vpm_value($vpm_group, 'twitter_card_player_image', get_queried_object_id()); break; } // Filter Twitter Card data so any values can be overridden externally from the plugin. $card_data = apply_filters('twitter_card_data', $card_data); // Gallery cards are not valid unless all four images are set // Photo cards are not valid unless there is a image set // If not valid, return empty. if ($card_type == 'gallery') { for ($i = 0; $i < 4; $i++) { if (!isset($card_data['image' . $i]) || empty($card_data['image' . $i])) { return; } } } else { if ($card_type == 'photo') { if (!isset($card_data['image']) || empty($card_data['image'])) { return; } } else { if ($card_type == 'product') { foreach (array('image', 'data1', 'label1', 'data2', 'label2') as $required) { if (!isset($card_data[$required]) || empty($card_data[$required])) { return; } } } else { if ($card_type == 'player') { foreach (array('title', 'description', 'image', 'player', 'player:width', 'player:height') as $required) { if (!isset($card_data[$required]) || empty($card_data[$required])) { return; } } if (!empty($card_data['player:stream']) && empty($card_data['player:stream:content_type'])) { return; } } } } } foreach ($card_data as $key => $value) { if (empty($value)) { continue; } printf('<meta name="twitter:%s" content="%s" />' . PHP_EOL, esc_attr($key), esc_attr($value)); } }
foreach ($term_list as $term) { $term_class .= $term->slug . ' '; } if (get_post_meta($project->ID, 'project_archived', true) != 1) { ?> <div class="project <?php echo rtrim($term_class, ' '); ?> "> <a href="<?php echo get_permalink($project->ID); ?> "> <div class="project-thumb" style="background-image: url('<?php if (class_exists('MultiPostThumbnails')) { echo MultiPostThumbnails::get_post_thumbnail_url('project', 'menu-image', $project->ID, $display_size); } ?> ');"> <div class="module-foreground-rollover" style="background: #<?php echo get_post_meta($project->ID, 'color_space', true); ?> ;" > <h4><?php echo get_the_title($project->ID); ?> </h4> </div> </div> </a> </div>
</div> <div class='ml-preview-article-list <?php echo get_option('ml_article_list_view_type', 'extended') == 'extended' ? 'ml-view-extended' : 'ml-view-compact'; ?> '> <div class='scroller'> <?php $posts = Mobiloud_App_Preview::get_preview_posts(); if (count($posts) > 0) { foreach ($posts as $post) { $imageUrl = null; if (has_post_thumbnail($post->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); $imageUrl = $image[0]; if (strlen(Mobiloud::get_option('ml_custom_featured_image')) > 0 && class_exists('MultiPostThumbnails')) { $customImageUrl = MultiPostThumbnails::get_post_thumbnail_url(get_post_type($post->ID), Mobiloud::get_option('ml_custom_featured_image'), $post->ID); if ($customImageUrl !== false) { $imageUrl = $customImageUrl; } } } ?> <div class='ml-preview-article'> <?php if ($imageUrl) { ?> <div class="ml-post-img-wrapper"> <img class='ml-preview-img' src='<?php echo $imageUrl; ?> '/>
<?php // ADD DUAL IMAGE IF APPROPRIATE if (get_post_meta($module->ID, 'module_size', true) == 'dual-small' || get_post_meta($module->ID, 'module_size', true) == 'dual-medium' || get_post_meta($module->ID, 'module_size', true) == 'dual-large') { ?> <div class="module-background-image"> <img id="background-image-<?php echo get_post_meta($module->ID, 'module_id', true); ?> " class="scroll_load" src="<?php if (class_exists('MultiPostThumbnails')) { echo MultiPostThumbnails::get_post_thumbnail_url('project', 'background-rollover-image', get_post_meta($module->ID, 'module_id', true), 'xsmall'); } ?> " /> <?php $images_script .= '"background-image-' . get_post_meta($module->ID, 'module_id', true) . '":"' . MultiPostThumbnails::get_post_thumbnail_url('project', 'background-rollover-image', get_post_meta($module->ID, 'module_id', true), $display_size) . '", '; ?> </div> <?php } ?> <?php if ($block_link) { ?> </a><?php } ?> </div> <?php
defined('ABSPATH') or die; /** * The template for single view category labor * */ ?> <article id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <?php if (class_exists('MultiPostThumbnails')) { $src = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image', $post->ID, 'full'); } ?> <?php if (empty($src)) { ?> <header class="post-beton-img"><div class="container"><h1><?php the_title(); ?> </h1></div></header> <?php } else { ?> <header class="post-second-img" style="background:url(<?php echo $src;
?> <a href="<?php echo $link_to; ?> "><?php } ?> <div class="grid-element <?php echo rtrim($term_class, ' '); ?> "> <div class="grid-image" style="background-image:url('<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?> ');" onmouseover="swapBackground(this,'<?php echo MultiPostThumbnails::get_post_thumbnail_url('post', 'rollover-image', $post->ID); ?> ');" onmouseout="swapBackground(this,'<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?> ');"></div> <p><b><?php $bev = get_the_category($post->ID); echo $bev[0]->name; ?> / </b><?php echo $post->post_title; ?> </p> </div> <?php
/** * Return a recipe image assigned to a post. * * @param null $size * * @return bool|mixed */ function fys_recipe_get_recipe_image_src($size = null) { if (class_exists('MultiPostThumbnails')) { return MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'recipe-image', get_the_ID(), $size); } return false; }