示例#1
6
function charity_vc_our_mission($atts, $content = null)
{
    extract(shortcode_atts(array('our_mission' => ''), $atts));
    $page_id = get_page_by_title($our_mission);
    $missionQuery = new WP_Query(array("page_id" => $page_id->ID));
    if ($missionQuery->have_posts()) {
        $missionQuery->the_post();
        $url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
        ?>
        <!-- Save Lives Section Start Here-->
        <section class="save-lives text-center parallax" style="background-image: url('<?php 
        echo esc_url($url[0]);
        ?>
')">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
                        <header class="page-header">
                            <h2><?php 
        the_title();
        ?>
</h2>
                            <?php 
        the_content();
        ?>
                        </header>
                    </div>
                </div>
            </div>
        </section>
        <!-- Save Lives Section Start Here-->
    <?php 
    }
    wp_reset_postdata();
}
示例#2
1
 function processData($atts)
 {
     $per_row = $atts['gallery_row_amount'];
     $col = (int) (12 / $per_row);
     $atts['col'] = $col;
     $atts['per_row'] = $per_row;
     $gallery_items = vc_param_group_parse_atts($atts['gallery_items']);
     $atts['amount'] = count($gallery_items);
     $i = 0;
     $items = array();
     foreach ($gallery_items as $item) {
         $items[$i]['id'] = self::GenerateId();
         // Headline
         $headline = self::Exists($item['headline'], '');
         $items[$i]['headline'] = $headline;
         // Image
         $attachment = wp_get_attachment_image_src($item['image'], 'full');
         $image_url = $attachment[0];
         $items[$i]['image_url'] = $image_url;
         // Text
         $text = self::Exists($item['text'], '');
         $items[$i]['image_text'] = $text;
         ++$i;
     }
     $atts['items'] = $items;
     return $atts;
 }
示例#3
0
 public function details($size)
 {
     if (!isset($this->sizes[$size])) {
         $this->sizes[$size] = wp_get_attachment_image_src($this->id, $size);
     }
     return $this->sizes[$size];
 }
示例#4
0
function thb_teammember($atts, $content = null)
{
    extract(shortcode_atts(array('image' => '', 'name' => '', 'position' => '', 'text' => '', 'advanced' => false, 'facebook' => '', 'twitter' => '', 'pinterest' => '', 'linkedin' => ''), $atts));
    $out = '';
    $img_id = preg_replace('/[^\\d]/', '', $image);
    $img = wp_get_attachment_image_src($img_id, 'full');
    $resized = aq_resize($img[0], 320, 340, true, false, true);
    $out .= '<aside class="team_member">';
    $out .= '<figure class="fresco">';
    $out .= '<img src="' . $resized[0] . '" width="' . $resized[1] . '" height="' . $resized[2] . '" alt="' . $name . '" />';
    $out .= '<div class="overlay"><div class="buttons ' . ($advanced ? 'advanced' : '') . '">';
    $out .= $name ? '<h5>' . $name . '</h5>' : '';
    $out .= $position ? '<h6>' . $position . '</h6>' : '';
    if ($facebook || $pinterest || $twitter || $linkedin) {
        $out .= '<div class="social_links">';
        if ($facebook) {
            $out .= '<a href="' . $facebook . '" class="facebook"><i class="fa fa-facebook"></i></a>';
        }
        if ($twitter) {
            $out .= '<a href="' . $twitter . '" class="twitter"><i class="fa fa-twitter"></i></a>';
        }
        if ($pinterest) {
            $out .= '<a href="' . $pinterest . '" class="pinterest"><i class="fa fa-pinterest"></i></a>';
        }
        if ($linkedin) {
            $out .= '<a href="' . $linkedin . '" class="linkedin"><i class="fa fa-linkedin"></i></a>';
        }
        $out .= '</div>';
    }
    $out .= '</div></div>';
    $out .= '</figure>';
    $out .= '</aside>';
    return $out;
}
示例#5
0
function get_thumb_urlfull($postID)
{
    $image_id = get_post_thumbnail_id($post);
    $image_url = wp_get_attachment_image_src($image_id, 'large');
    $image_url = $image_url[0];
    return $image_url;
}
示例#6
0
function vr_set_featured_background()
{
    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), full, false);
    if ($image_url[0]) {
        ?>
     <style>
     
       html,body {
       height:100%;
       margin:0!important;
       }
       body {
       background: url(<?php 
        echo $image_url[0];
        ?>
) #000 center top;
       background-size: contain;
       height: 100vh;
       }
       @media all and (max-width: 940px) {
        body {
          height: auto;
          background-size: cover;
          background-position: center top;
        }
      }
     </style>
   <?php 
    }
    //end if statement
}
示例#7
0
function get_src($image, $size)
{
    $upload_url = wp_upload_dir();
    $upload_url = $upload_url['baseurl'];
    $src = wp_get_attachment_image_src($image->ID, $size);
    return $src[0];
}
示例#8
0
 /**
  * Render the widget in frontend
  *
  * @param array $args
  * @param array $instance
  * @return string
  */
 function get_widget($args, $instance)
 {
     extract(wp_parse_args($instance, array('align' => '', 'animation' => '', 'class' => '', 'style' => '', 'size' => '')));
     if (is_admin()) {
         return "<center><i class='icon-picture  icon-4x'></i></center>";
     }
     if (!empty($image['url'])) {
         if ($animation != "no-animation") {
             $class = "image animated_image animate_when_visible " . $animation;
         }
         $link = get_url($link);
         if ($image['id'] > 0 && $size != '') {
             $img = wp_get_attachment_image_src($image['id'], $size);
             $use_image = " src='{$img[0]}' width='{$img[1]}' height='{$img[2]}' ";
         } else {
             $img = $image['url'];
             $use_image = " src='{$img}' ";
         }
         if ($link) {
             $output = "<a href='" . $link . "' ><img class='img-responsive {$align} {$class} {$style}'  data-animation='" . esc_attr($animation) . "' {$use_image} alt='' /></a>";
         } else {
             $output = "<img class='img-responsive {$align} {$class} {$style}' ' data-animation='" . esc_attr($animation) . "' alt='' {$use_image} />";
         }
     }
     return $output;
 }
示例#9
0
 /**
  * Get field HTML
  *
  * @param string $html
  * @param mixed  $meta
  * @param array  $field
  *
  * @return string
  */
 static function html($html, $meta, $field)
 {
     global $wpdb;
     $i18n_msg = _x('Uploaded files', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_del_file = _x('Delete this file', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_delete = _x('Delete', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_edit = _x('Edit', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_title = _x('Upload files', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_more = _x('Add another file', 'image upload', RWMB_TEXTDOMAIN);
     $html = wp_nonce_field("rwmb-delete-file_{$field['id']}", "nonce-delete-file_{$field['id']}", false, false);
     $html .= wp_nonce_field("rwmb-reorder-images_{$field['id']}", "nonce-reorder-images_{$field['id']}", false, false);
     $html .= "<input type='hidden' class='field-id' value='{$field['id']}' />";
     // Uploaded images
     if (!empty($meta)) {
         $html .= "<h4>{$i18n_msg}</h4>";
         $html .= "<ul class='rwmb-images rwmb-uploaded'>";
         foreach ($meta as $image) {
             $src = wp_get_attachment_image_src($image, 'thumbnail');
             $src = $src[0];
             $link = get_edit_post_link($image);
             $html .= "<li id='item_{$image}'>\n\t\t\t\t\t\t<img src='{$src}' />\n\t\t\t\t\t\t<div class='rwmb-image-bar'>\n\t\t\t\t\t\t\t<a title='{$i18n_edit}' class='rwmb-edit-file' href='{$link}' target='_blank'>{$i18n_edit}</a> |\n\t\t\t\t\t\t\t<a title='{$i18n_del_file}' class='rwmb-delete-file' href='#' rel='{$image}'>{$i18n_delete}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>";
         }
         $html .= '</ul>';
     }
     // Show form upload
     $html .= "\n\t\t\t<h4>{$i18n_title}</h4>\n\t\t\t<div class='new-files'>\n\t\t\t\t<div class='file-input'><input type='file' name='{$field['id']}[]' /></div>\n\t\t\t\t<a class='rwmb-add-file' href='#'>{$i18n_more}</a>\n\t\t\t</div>";
     return $html;
 }
示例#10
0
function generate_image_filed($title, $id, $name, $value, $class, $name_btn, $class_btn)
{
    $out_filed = '';
    $out_filed .= '<tr valign="top">';
    $out_filed .= '<th scope="row">' . esc_attr($title) . '</th>';
    $out_filed .= '<td>';
    $out_filed .= '<filedset>';
    $out_filed .= '<input type="hidden" id="' . esc_attr($id) . '" name="lib_options[' . $name . ']" value="' . esc_attr($value) . '" />';
    $out_filed .= '<div class="img-container">';
    $url = '';
    if ($value != '') {
        $image = wp_get_attachment_image_src($value, 'full');
        $url = esc_url($image[0]);
    }
    $out_filed .= '<div class="' . esc_attr($class) . '" style="background-image:url(' . $url . ')">';
    if ($value) {
        $out_filed .= '<input class="button button-primary delete-img remove" type="button" value="x" />';
    }
    $out_filed .= '</div>';
    $out_filed .= '<input type="button" class="' . esc_attr($class_btn) . '" value="' . esc_attr($name_btn) . '"/>';
    $out_filed .= '</div>';
    $out_filed .= '</filedset>';
    $out_filed .= '</td>';
    $out_filed .= '</tr>';
    echo $out_filed;
}
function al_portfolio_meta_tags()
{
    $post_type = get_post_type();
    if ('portfolio' == $post_type) {
        $title = get_post_meta(get_the_ID(), "al_pf_og_title", TRUE);
        $title = !empty($title) ? $title : get_the_title();
        $meta = array('og:title' => $title, 'og:url' => get_permalink());
        $desc = get_post_meta(get_the_ID(), "al_pf_og_description", TRUE);
        $desc = !empty($desc) ? $desc : false;
        if ($desc) {
            $meta['og:description'] = $desc;
        }
        if (has_post_thumbnail()) {
            $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
            $meta['og:image'] = $thumbnail[0];
        }
        if (get_post_format() == 'gallery') {
            $images = rwmb_meta('al_pf_gallery_images', 'type=image&size=full');
            if (is_array($images)) {
                foreach ($images as $image) {
                    $meta['images'][] = $image['url'];
                }
            }
        }
        foreach ($meta as $key => $value) {
            if ($key == 'images') {
                foreach ($value as $image) {
                    echo '<meta property="og:image" content="' . $image . '" />';
                }
            } else {
                echo '<meta property="' . $key . '" content="' . $value . '" />';
            }
        }
    }
}
示例#12
0
function get_image_url()
{
    $image_id = get_post_thumbnail_id();
    $image_url = wp_get_attachment_image_src($image_id, 'large');
    $image_url = $image_url[0];
    echo $image_url;
}
示例#13
0
function largo_get_avatar_src($id_or_email, $size)
{
    $avatar_id = largo_get_user_avatar_id($id_or_email);
    if (empty($avatar_id)) {
        return false;
    }
    global $_wp_additional_image_sizes;
    $copy = $_wp_additional_image_sizes;
    usort($copy, function ($a, $b) {
        return $a['width'] - $b['width'];
    });
    $square_image_sizes = array_filter($copy, function ($arg) {
        return $arg['width'] / $arg['height'] == 1;
    });
    $requested_size = array($size, $size);
    foreach ($square_image_sizes as $key => $val) {
        if (round((double) ($val['width'] / $val['height']), 1, PHP_ROUND_HALF_DOWN) == round((double) ($requested_size[0] / $requested_size[1]), 1, PHP_ROUND_HALF_DOWN)) {
            // Try to find an image size equal to or just slightly larger than what was requested
            if ($val['width'] >= $requested_size[0]) {
                $requested_size = array($val['width'], $val['height']);
                break;
            }
            // If we can't find an image size, set the requested size to the largest of the
            // square sizes available
            if (end($square_image_sizes) == $square_image_sizes[$key]) {
                $requested_size = array($val['width'], $val['height']);
            }
        }
    }
    return wp_get_attachment_image_src($avatar_id, $requested_size);
}
示例#14
0
function degrona15_add_candidate_content()
{
    if (is_front_page()) {
        // If De_Grona_Ehdokas-plugin is installed, retrieve $instance of the plugin
        if (function_exists('De_Grona_Ehdokas')) {
            $instance = De_Grona_Ehdokas::instance();
            if ($instance->get_candidate_data('degrona15_candidate_enable_home_page')) {
                $bg_img_id = $instance->get_candidate_data('degrona15_candidate_site_jumbotron');
                if ($bg_img_id) {
                    $bg_img = wp_get_attachment_image_src($bg_img_id, 'full');
                } else {
                    $bg_img[0] = $instance->get_jumbtoron_default_bg();
                }
                $data = $instance->get_candidate_home_page_data();
                ?>

        <div class='de_grona_candidate_jumbotron' style='background-image: url(<?php 
                echo $bg_img[0];
                ?>
);'>
          <!-- <div class='row'> -->
          <?php 
                echo $data;
                ?>
          <!-- </div> -->
        </div>
      <?php 
            }
        }
    }
}
示例#15
0
 /**
  * Full attachment image url.
  *
  * Gets a post ID and returns the url for the 'full' size of the attachment
  * set as featured image.
  * 
  * @param  int $id 	 The post ID.
  * @since  1.5.9
  * @return string    The featured image url for the 'full' size.
  */
 public function get_full_img_src($id)
 {
     $thumb_id = get_post_thumbnail_id($id);
     $size = isset($this->settings->thumb_size) ? $this->settings->thumb_size : 'medium';
     $img = wp_get_attachment_image_src($thumb_id, $size);
     return $img[0];
 }
示例#16
0
 function wm_logo()
 {
     //Helper variables
     $output = '';
     $blog_info = apply_filters('wmhook_wm_logo_blog_info', array('name' => trim(get_bloginfo('name')), 'description' => trim(get_bloginfo('description'))));
     $args = apply_filters('wmhook_wm_logo_args', array('title_att' => $blog_info['description'] ? $blog_info['name'] . ' | ' . $blog_info['description'] : $blog_info['name'], 'logo_image' => function_exists('jetpack_get_site_logo') ? absint(jetpack_get_site_logo('id')) : false, 'logo_type' => 'text', 'url' => home_url('/')));
     //Preparing output
     //Logo image
     if (!empty($args['logo_image'])) {
         $img_id = is_numeric($args['logo_image']) ? absint($args['logo_image']) : wm_get_image_id_from_url($args['logo_image']);
         if ($img_id) {
             $logo_url = wp_get_attachment_image_src($img_id, 'full');
             $atts = (array) apply_filters('wmhook_wm_logo_image_atts', array('alt' => esc_attr(sprintf(_x('%s logo', 'Site logo image "alt" HTML attribute text.', 'wm_domain'), $blog_info['name'])), 'title' => esc_attr($args['title_att']), 'class' => ''));
             $args['logo_image'] = wp_get_attachment_image($img_id, 'full', false, $atts);
         }
         $args['logo_type'] = 'img';
     }
     $args['logo_image'] = apply_filters('wmhook_wm_logo_logo_image', $args['logo_image']);
     //Logo HTML
     $output .= '<div class="site-branding">';
     $output .= '<h1 class="' . apply_filters('wmhook_wm_logo_class', 'site-title logo type-' . $args['logo_type'], $args) . '">';
     $output .= '<a href="' . esc_url($args['url']) . '" title="' . esc_attr($args['title_att']) . '">';
     if ('text' === $args['logo_type']) {
         $output .= '<span class="text-logo">' . $blog_info['name'] . '</span>';
     } else {
         $output .= $args['logo_image'];
     }
     $output .= '</a></h1>';
     if ($blog_info['description']) {
         $output .= '<h2 class="site-description">' . $blog_info['description'] . '</h2>';
     }
     $output .= '</div>';
     //Output
     echo apply_filters('wmhook_wm_logo_output', $output);
 }
示例#17
0
function rs_option_page_new()
{
    $slider = new WP_Query(array('post_type' => 'slideshow', 'order' => 'ASC'));
    if ($slider->have_posts()) {
        ?>

		<ul class="bxslider">
			<?php 
        while ($slider->have_posts()) {
            $slider->the_post();
            ?>
				<li>
					<?php 
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $url = $thumb['0'];
            ?>
					<img src="<?php 
            echo $url;
            ?>
" title="<?php 
            the_content();
            ?>
">
				</li>
			<?php 
        }
        ?>
		</ul>
	<?php 
    } else {
        ?>
		<div><h2>This plase slider</h2></div>
	<?php 
    }
}
示例#18
0
 function testResizedByArray()
 {
     $image = wp_get_attachment_image_src($this->attachment, array(300, 300));
     $this->assertEquals(300, $image[1]);
     $this->assertEquals(242, $image[2]);
     $this->assertTrue((bool) strpos($image[0], '/cache/'));
 }
示例#19
0
/**
 * Returns a set of image attachment links based on size.
 *
 * @since 1.0.0
 * @access public
 * @return string
 */
function hoot_get_image_size_links()
{
    /* If not viewing an image attachment page, return. */
    if (!wp_attachment_is_image(get_the_ID())) {
        return;
    }
    /* Set up an empty array for the links. */
    $links = array();
    /* Get the intermediate image sizes and add the full size to the array. */
    $sizes = get_intermediate_image_sizes();
    $sizes[] = 'full';
    /* Loop through each of the image sizes. */
    foreach ($sizes as $size) {
        /* Get the image source, width, height, and whether it's intermediate. */
        $image = wp_get_attachment_image_src(get_the_ID(), $size);
        /* Add the link to the array if there's an image and if $is_intermediate (4th array value) is true or full size. */
        if (!empty($image) && (true === $image[3] || 'full' == $size)) {
            /* Translators: Media dimensions - 1 is width and 2 is height. */
            $label = sprintf(__('%1$s &#215; %2$s', 'chromatic'), number_format_i18n(absint($image[1])), number_format_i18n(absint($image[2])));
            $links[] = sprintf('<a class="image-size-link">%s</a>', $label);
        }
    }
    /* Join the links in a string and return. */
    return join(' <span class="sep">/</span> ', $links);
}
示例#20
0
function sys_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts));
    $out = '<div class="widget_postslist sc">';
    $out .= '<ul>';
    global $wpdb;
    $myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}");
    foreach ($myposts as $post) {
        $post_date = $post->post_date;
        $post_date = mysql2date('F j, Y', $post_date, false);
        $out .= "<li>";
        if ($thumb == "true") {
            $thumbid = get_post_thumbnail_id($post->ID);
            $imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
            $out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
            if ($thumbid) {
                $out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', '');
            } else {
                //$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'"  alt="' .$post->post_title. '" />';
            }
            $out .= '</a></div>';
        }
        $out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
        if ($postdate == "true") {
            $out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
        } else {
            $out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
        }
        $out .= '</div></li>';
    }
    $out .= '</ul></div>';
    return $out;
    wp_reset_query();
}
示例#21
0
 /**
  * Fetch the promotional book and returns
  * an object with associated datas. Used for
  * the home page promo book section.
  *
  * @param int $id The promoted book id.
  * @return \stdClass
  */
 public function getPromoBook($id)
 {
     $book = new stdClass();
     // Default values.
     $book->title = '';
     $book->author = '';
     $book->image = '';
     $book->color = '';
     $book->link = '';
     // Handle the case where a book is selected.
     if (!empty($id) && 'none' !== $id) {
         $query = new WP_Query(array('post_type' => $this->slug, 'p' => $id));
         $results = $query->get_posts();
         $results = $results[0];
         // Title
         $book->title = $results->post_title;
         // Author
         $book->author = Meta::get($results->ID, 'author');
         // Promo image
         $imageId = Meta::get($results->ID, 'promo-image');
         $image = wp_get_attachment_image_src($imageId, 'book-promo');
         $book->image = $image[0];
         // Color
         $book->color = Meta::get($results->ID, 'color');
         // Permalink
         $book->link = get_permalink($results->ID);
     }
     return $book;
 }
 public function is_image_missing($image)
 {
     global $_wp_additional_image_sizes;
     $sizes = array_map(function ($size) {
         return $size['width'] . 'x' . $size['height'];
     }, (array) $_wp_additional_image_sizes);
     foreach (array('thumbnail', 'medium', 'large') as $size) {
         $sizes[] = get_option($size . '_size_w') . 'x' . get_option($size . '_size_h');
     }
     $todo = array();
     if (in_array(implode('x', $image['size']), $sizes)) {
         return false;
     }
     $size = $image['size'];
     $src = wp_get_attachment_image_src($image['id'], array($size[0], $size[1]));
     if ($src) {
         if ($src[0] === $image['url']) {
             return false;
         }
     }
     if (strpos($image['url'], $this->upload_dir['baseurl']) !== 0) {
         return false;
     }
     $image_path = str_replace($this->upload_dir['baseurl'], $this->upload_dir['basedir'], $image['url']);
     if (file_exists($image_path)) {
         return false;
     }
     return true;
 }
function image_cpt_shortcode($attr)
{
    if ($attr['page'] <= 10) {
        $per_page['page'] = $attr['page'];
    } else {
        $per_page['page'] = 10;
    }
    $output = '<h2 class="winner-title">Hall of Winners</h2><h3 class="winner-subtitle">Congratulations to all of our winners</h3>';
    $args = array('post_type' => 'image_post_type', 'posts_per_page' => $per_page['page']);
    $loop = new WP_query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            $output .= '<div class="winner-div"><h3>';
            $output .= get_the_title();
            $output .= '</h3>';
            if (has_post_thumbnail()) {
                // check if the post has a post thumbnail assigned to it.
                $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full');
                $url = $thumb['0'];
                $output .= '<img src="' . $url . '"/>';
            }
            $output .= '</div>';
        }
    } else {
        // if no content, include the "no posts found" template.
        get_template_part('content', 'none');
    }
    return $output;
}
function motopressCEGetAttachmentThumbnail()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    $motopressCELang = motopressCEGetLanguageDict();
    if (isset($_POST['id']) && !empty($_POST['id'])) {
        $id = (int) trim($_POST['id']);
        $attachment = get_post($id);
        if (!empty($attachment) && $attachment->post_type === 'attachment') {
            if (wp_attachment_is_image($id)) {
                $srcMedium = wp_get_attachment_image_src($id, 'medium');
                $srcFull = wp_get_attachment_image_src($id, 'full');
                if (isset($srcMedium[0]) && !empty($srcMedium[0]) && isset($srcFull[0]) && !empty($srcFull[0])) {
                    $attachmentImageSrc = array();
                    $attachmentImageSrc['medium'] = $srcMedium[0];
                    $attachmentImageSrc['full'] = $srcFull[0];
                    wp_send_json($attachmentImageSrc);
                } else {
                    motopressCESetError($motopressCELang->CEAttachmentImageSrc);
                }
            } else {
                motopressCESetError($motopressCELang->CEAttachmentNotImage);
            }
        } else {
            motopressCESetError($motopressCELang->CEAttachmentEmpty);
        }
    } else {
        motopressCESetError($motopressCELang->CEAttachmentThumbnailError);
    }
    exit;
}
示例#25
0
function vr_set_featured_background()
{
    $page_for_posts = get_option('page_for_posts');
    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), full, false);
    if ($image_url[0]) {
        ?>
          <style>
            html,body {
                height:100%;
                margin:0!important;
              }
              body {
                background:url(<?php 
        echo $image_url[0];
        ?>
) #fff center center repeat;
              }
              .wrapper {
                height: auto;
              }
          </style>
        <?php 
    }
    //end if statement
}
 public function display()
 {
     self::createUploaderScript();
     $this->echoOptionHeader();
     // display the preview image
     $value = $this->getValue();
     if (is_numeric($value)) {
         // gives us an array with the first element as the src or false on fail
         $value = wp_get_attachment_image_src($value, array(150, 150));
     }
     if (!is_array($value)) {
         $value = $this->getValue();
     } else {
         $value = $value[0];
     }
     // $value = '101,96';
     $value_arr = explode(',', $value);
     foreach ($value_arr as $k => $v) {
         $previewImage = '';
         if (!empty($v)) {
             $size = !empty($option->settings['size']) ? $option->settings['size'] : 'thumbnail';
             if (is_numeric($v)) {
                 $attachment = wp_get_attachment_image_src($v, $size);
                 $v = $attachment[0];
             }
             $previewImage = "<i class='dashicons dashicons-no-alt remove'></i><img style='max-width: 150px; max-height: 150px; margin-top: 0px; margin-left: 0px;' src='" . esc_url($v) . "' style='display: none'/>";
             echo "<div class='thumbnail used-thumbnail tf-image-preview'>" . $previewImage . '</div>';
         }
     }
     echo "<div class='thumbnail tf-image-preview'></div>";
     printf('<input name="%s" placeholder="%s" id="%s" type="hidden" value="%s" />', $this->getID(), $this->settings['placeholder'], $this->getID(), esc_attr($this->getValue()));
     $this->echoOptionFooter();
 }
示例#27
0
 protected function content($atts, $content = null)
 {
     $title = $address = $size = $zoom = $pin_image = $type = $el_position = $width = $el_class = '';
     extract(shortcode_atts(array('title' => '', 'full_width' => '', 'address' => '', 'size' => 200, 'zoom' => 14, 'pin_image' => '', 'type' => 'm', 'el_position' => '', 'width' => '1/1', 'el_class' => ''), $atts));
     $output = '';
     if ($address == '') {
         return null;
     }
     $el_class = $this->getExtraClass($el_class);
     $width = wpb_translateColumnWidthToSpan($width);
     $size = str_replace(array('px', ' '), array('', ''), $size);
     $map_coords = map_embed($address);
     $img_url = wp_get_attachment_image_src($pin_image, 'full');
     if ($full_width == "yes") {
         $output .= "\n\t" . '<div class="wpb_gmaps_widget full-width wpb_content_element ' . $width . $el_class . '">';
     } else {
         $output .= "\n\t" . '<div class="wpb_gmaps_widget wpb_content_element ' . $width . $el_class . '">';
     }
     $output .= "\n\t\t" . '<div class="wpb_wrapper">';
     $output .= $title != '' ? "\n\t\t\t" . '<h3 class="wpb_heading wpb_video_heading">' . $title . '</h3>' : '';
     $output .= '<div class="wpb_map_wraper"><div class="map-canvas" style="width:100%;height:' . $size . 'px;" data-address="' . $address . '" data-lat="' . $map_coords['lat'] . '" data-long="' . $map_coords['long'] . '" data-zoom="' . $zoom . '" data-maptype="' . $type . '" data-pinimage="' . $img_url[0] . '"></div></div>';
     $output .= "\n\t\t" . '</div> ' . $this->endBlockComment('.wpb_wrapper');
     $output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
     $output = $this->startRow($el_position) . $output . $this->endRow($el_position);
     global $include_maps;
     $include_maps = true;
     return $output;
 }
示例#28
0
function replace_default_image_url($content)
{
    // Extract images into the $matches folder
    if (!preg_match_all('/<img [^>]+>/', $content, $matches)) {
        return $content;
    }
    $selected_images = $attachment_ids = array();
    // Cycle through images
    foreach ($matches[0] as $image) {
        if (preg_match('/wp-image-([0-9]+)/i', $image, $class_id) && ($attachment_id = absint($class_id[1]))) {
            /*
             * If exactly the same image tag is used more than once, overwrite it.
             * All identical tags will be replaced later with 'str_replace()'.
             */
            $selected_images[$image] = $attachment_id;
            // Overwrite the ID when the same image is included more than once.
            $attachment_ids[$attachment_id] = true;
        }
    }
    foreach ($selected_images as $image => $attachment_id) {
        $image_src = preg_match('/src="([^"]+)"/', $image, $match_src) ? $match_src[1] : '';
        list($image_src) = explode('?', $image_src);
        $original_src = wp_get_attachment_image_src($attachment_id, 'full');
        $original_src = $original_src[0];
        if ($image_src === $original_src) {
            $extralarge_src = wp_get_attachment_image_src($attachment_id, 'extralarge');
            $extralarge_src = $extralarge_src[0];
            $new_image = preg_replace('/ src="([^"]+)"/', ' src="' . $extralarge_src . '"', $image);
            $content = str_replace($image, $new_image, $content);
        }
    }
    return $content;
}
示例#29
0
function print_blog_thumbnail($post_id, $item_size)
{
    $thumbnail_types = get_post_meta($post_id, 'post-option-thumbnail-types', true);
    if ($thumbnail_types == "Image" || empty($thumbnail_types)) {
        $thumbnail_id = get_post_thumbnail_id($post_id);
        $thumbnail = wp_get_attachment_image_src($thumbnail_id, $item_size);
        $alt_text = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
        if (!empty($thumbnail)) {
            echo '<div class="blog-thumbnail-image">';
            echo '<a href="' . get_permalink() . '"><img src="' . $thumbnail[0] . '" alt="' . $alt_text . '"/></a></div>';
        }
    } else {
        if ($thumbnail_types == "Video") {
            $video_link = get_post_meta($post_id, 'post-option-thumbnail-video', true);
            echo '<div class="blog-thumbnail-video">';
            echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
            echo '</div>';
        } else {
            if ($thumbnail_types == "Slider") {
                $slider_xml = get_post_meta($post_id, 'post-option-thumbnail-xml', true);
                $slider_xml_dom = new DOMDocument();
                $slider_xml_dom->loadXML($slider_xml);
                echo '<div class="blog-thumbnail-slider">';
                echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
                echo '</div>';
            }
        }
    }
}
示例#30
0
 public function get($type = "", $id = "", $size = "", $attr = array())
 {
     if (is_array($id) && $id["id"]) {
         $id = $id["id"];
     }
     if (!$id) {
         $id = get_post_thumbnail_id(get_the_ID());
     }
     if (!$id) {
         $id = get_field('image', get_the_ID());
         $id = $id["id"];
     }
     if (!$id) {
         $id = get_field('placeholder', 'options');
     }
     if (!$id) {
         return;
     }
     if ($type == "html") {
         return wp_get_attachment_image($id, $size);
     } else {
         if ($type == "url") {
             return reset(wp_get_attachment_image_src($id, $size));
         } else {
             if ($type == "") {
                 return wp_get_attachment_metadata($id);
             } else {
                 $res = wp_get_attachment_metadata($id);
                 return $res[$type];
             }
         }
     }
 }