当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_get_attachment_image_url函数代码示例

本文整理汇总了PHP中wp_get_attachment_image_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_attachment_image_url函数的具体用法?PHP wp_get_attachment_image_url怎么用?PHP wp_get_attachment_image_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_get_attachment_image_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Get menu item meta value
  *
  * @since  0.3.0
  * @since  0.9.0  Add $defaults parameter.
  * @param  int    $id       Menu item ID.
  * @param  array  $defaults Optional. Default value.
  * @return array
  */
 public static function get($id, $defaults = array())
 {
     $defaults = wp_parse_args($defaults, self::$defaults);
     $value = get_post_meta($id, self::KEY, true);
     $value = wp_parse_args((array) $value, $defaults);
     // Backward-compatibility.
     if (empty($value['icon']) && !empty($value['type']) && !empty($value["{$value['type']}-icon"])) {
         $value['icon'] = $value["{$value['type']}-icon"];
     }
     if (!empty($value['width'])) {
         $value['svg_width'] = $value['width'];
     }
     unset($value['width']);
     if (isset($value['position']) && !in_array($value['position'], array('before', 'after'))) {
         $value['position'] = $defaults['position'];
     }
     if (isset($value['size']) && !isset($value['font_size'])) {
         $value['font_size'] = $value['size'];
         unset($value['size']);
     }
     // The values below will NOT be saved
     if (!empty($value['icon']) && in_array($value['type'], array('image', 'svg'))) {
         $value['url'] = wp_get_attachment_image_url($value['icon'], 'thumbnail', false);
     }
     return $value;
 }
开发者ID:xeiter,项目名称:timeplannr,代码行数:35,代码来源:meta.php

示例2: get_the_post_thumbnail_url

 function get_the_post_thumbnail_url($post = null, $size = 'post-thumbnail')
 {
     $post_thumbnail_id = get_post_thumbnail_id($post);
     if (!$post_thumbnail_id) {
         return false;
     }
     return wp_get_attachment_image_url($post_thumbnail_id, $size);
 }
开发者ID:benjaminmedia,项目名称:wp-duplicate-featured-image,代码行数:8,代码来源:helper.php

示例3: get_html_noresp

 public function get_html_noresp($media_id, $size = null, array $attrs = array(), $square = false, $use_fallback = false)
 {
     $img_src = wp_get_attachment_image_url($media_id, $size);
     if (empty($img_src)) {
         $result = $use_fallback ? call_user_func_array(array($this, 'get_html_fallback'), func_get_args()) : false;
         return $result;
     }
     $attrs = array_merge(array('src' => $img_src), $attrs);
     $result = \Cibulka::Base('HTML', 'img', $attrs, true);
     return $result;
 }
开发者ID:cibulka,项目名称:cibulka-wp-plugin-base,代码行数:11,代码来源:Image.php

示例4: icon_picker_get_icon_url

/**
 * Get Icon URL
 *
 * @since  0.2.0
 *
 * @param  string  $type  Icon type.
 * @param  mixed   $id    Icon ID.
 * @param  string  $size  Optional. Icon size, defaults to 'thumbnail'.
 *
 * @return string
 */
function icon_picker_get_icon_url($type, $id, $size = 'thumbnail')
{
    $url = '';
    if (!in_array($type, array('image', 'svg'))) {
        return $url;
    }
    if (empty($id)) {
        return $url;
    }
    return wp_get_attachment_image_url($id, $size, false);
}
开发者ID:vburlak,项目名称:wp-icon-picker,代码行数:22,代码来源:base.php

示例5: formatted_items

 protected function formatted_items($type)
 {
     $formatted_items = [];
     switch ($type) {
         case 'tree-selection':
             foreach ($this->items as $tree) {
                 $attachment_id = get_post_thumbnail_id($tree->ID);
                 $img_thumb_url = wp_get_attachment_image_src($attachment_id, 'selection-thumb');
                 $img_url = wp_get_attachment_image_url($attachment_id, 'full');
                 $formatted_items[] = array('ID' => ForestUtils::get_instance()->get_js_object(array('ID' => $tree->ID, 'title' => $tree->post_title), true), 'post_title' => $tree->post_title, 'img' => sprintf('<a href="%s" class="thickbox"><img src="%s" style="width:%dpx;height:%dpx"/></a>', $img_url, $img_thumb_url[0], $img_thumb_url[1], $img_thumb_url[2]));
             }
             break;
     }
     return $formatted_items;
 }
开发者ID:shaulfiron,项目名称:forest-manager,代码行数:15,代码来源:TreeSpeciesDbQuery.php

示例6: cultiv8_get_site_logo

function cultiv8_get_site_logo()
{
    if (function_exists('get_custom_logo')) {
        // Try to use WP4.5 built in site logo feature
        return wp_get_attachment_image_url(get_theme_mod('custom_logo'), 'full');
    } elseif (function_exists('jetpack_get_site_logo')) {
        // If not available, try Jetpack's site logo feature
        return jetpack_get_site_logo();
    } else {
        // Last resort, try our own feature
        if (get_theme_mod('cultiv8_site_logo')) {
            return get_theme_mod('cultiv8_site_logo');
        } else {
            return '';
        }
    }
}
开发者ID:serranoabq,项目名称:cultiv8,代码行数:17,代码来源:images.php

示例7: get_company_info

 public function get_company_info($mode = '', $for_date = null, $logo_size = 'medium')
 {
     $company = Util::get_relevant($this->get_meta('company'), $for_date);
     if (empty($mode)) {
         return $company;
     }
     switch ($mode) {
         case 'name':
             return $company['name'];
         case 'logo_url':
             return wp_get_attachment_image_url($company['logo'], $logo_size);
         case 'logo_path':
             return Util::get_attachment_image_path($company['logo'], $logo_size);
         case 'logo_id':
         default:
             return $company['logo'];
     }
 }
开发者ID:Leaves-Webdesign,项目名称:easy-customer-invoices,代码行数:18,代码来源:Vendor.php

示例8: convert

 /**
  * Convert markdown image to html image tag
  *
  * @return string
  */
 public function convert()
 {
     $time = get_the_time('Y/m', $this->post_id);
     $wp_upload_dir = wp_upload_dir($time, $this->post_id);
     $this->upload_url = untrailingslashit($wp_upload_dir['url']);
     return preg_replace_callback('/\\!\\[(.*?)\\]\\((.+?)\\)/sm', function ($matches) {
         $pathinfo = pathinfo($matches[2]);
         $Unicode_Normalization = new Markdown_Importer_Unicode_Normalization($matches[2]);
         $filename = $Unicode_Normalization->convert();
         $filename = sha1($filename) . '.' . $pathinfo['extension'];
         $attachment_url = $this->upload_url . '/' . $filename;
         $attachment_id = attachment_url_to_postid($attachment_url);
         $full = wp_get_attachment_image_url($attachment_id, 'full');
         $large = wp_get_attachment_image_url($attachment_id, 'large');
         if (!$full || !$large) {
             return;
         }
         return sprintf('<a class="markdown-importer-image-link" href="%1$s"><img class="size-large wp-image-%2$d markdown-importer-image" src="%3$s" alt="%4$s" /></a>', esc_url($full), esc_attr($attachment_id), esc_url($large), esc_attr($matches[1]));
     }, $this->content);
 }
开发者ID:inc2734,项目名称:markdown-importer,代码行数:25,代码来源:converting-image.php

示例9: gannet_responsive_thumbnail

/**
 *
 */
function gannet_responsive_thumbnail($attachment_id)
{
    $src = wp_get_attachment_image_url($attachment_id, 'medium');
    $srcset = wp_get_attachment_image_srcset($attachment_id, 'medium');
    $alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
    ?>
	<img src="<?php 
    echo esc_url($src);
    ?>
"
		class="post-thumbnail"
		alt="<?php 
    echo esc_textarea($alt);
    ?>
"
		srcset="<?php 
    echo esc_attr($srcset);
    ?>
"
		sizes="768px, (min-width: 768px) 300px">
  <?php 
}
开发者ID:duanecilliers,项目名称:gannet,代码行数:25,代码来源:template-tags.php

示例10: get_brick_html

 /**
  * @return string
  */
 protected function get_brick_html()
 {
     // Some stuff just to show off features
     $this->set_data_item('demo_data_item', 'I am some test data set on the fly by the brick.');
     $this->set_data_item('demo_data_item', 'I am some test data set on the fly by the brick in a group.', true, 'demo_group');
     $this->set_data_item('demo_data_item_2', 'I am some _more_ test data set on the fly by the brick in a group.', true, 'demo_group');
     // Example of how to check if brick has layout
     // var_dump($this->has_brick_layout('demo-layout-1'));
     // Example of how to get all layouts
     // var_dump($this->get_brick_layouts());
     $bg_img = $this->get_field('bg_img');
     if (!empty($bg_img)) {
         $this->set_inline_css('padding-top', '50px');
         $this->set_inline_css('background-image', 'url(' . wp_get_attachment_image_url($bg_img, 'full') . ')', 'inner');
     }
     $this->set_inline_css('border', 'solid 2px #000', 'inner');
     $html = '
       <div class="row">
         <div class="col-xs-12">
             <h2>' . $this->get_field('headline') . '</h2>
         </div>
       </div>
       <div class="row">
         <div class="col-xs-12">
             <ul>';
     if ($this->have_rows('buttons')) {
         while ($this->have_rows('buttons')) {
             $this->the_row();
             $html .= '<li>' . $this->get_child_brick_in_repeater('buttons', 'button', 'demo_button')->get_html() . '</li>';
         }
     }
     $html .= '
           </ul>
         </div>
       </div>
     ';
     return $html;
 }
开发者ID:folbert,项目名称:fewbricks,代码行数:41,代码来源:demo-buttons-list.php

示例11: ev_get_density_image

/**
 * Return the markup for an image specifying a different srcset parameter according
 * to the available densities.
 *
 * @since 1.0.0
 * @param array $data The image data.
 * @param string $type The image size.
 * @param string $breakpoint The breakpoint name.
 * @return string
 */
function ev_get_density_image($data, $size = 'full', $breakpoint = 'desktop')
{
    if (empty($data[$breakpoint]['1']['id'])) {
        return '';
    }
    $src = wp_get_attachment_image_url($data[$breakpoint]['1']['id'], $size);
    if (empty($src)) {
        return '';
    }
    $srcset = array();
    $densities = ev_get_densities();
    array_shift($densities);
    foreach ($densities as $density => $label) {
        $density_src = wp_get_attachment_image_url($data[$breakpoint][$density]['id'], $size);
        if (!empty($density_src)) {
            $srcset[] = $density_src . ' ' . $density . 'x';
        }
    }
    $args = array();
    if (!empty($srcset)) {
        $args['srcset'] = esc_attr(implode(', ', $srcset));
    }
    return wp_get_attachment_image($data[$breakpoint]['1']['id'], $size, false, $args);
}
开发者ID:Justevolve,项目名称:evolve-framework,代码行数:34,代码来源:images.php

示例12: wp_get_attachment_image

            // (thumbnail, medium, large, full or custom size)
            if ($image) {
                echo wp_get_attachment_image($image, $size);
            }
            ?>
				</div>
				<?php 
            the_content();
            ?>
				<div class="links-wrap">
					<div class="addthis_sharing_toolbox"></div>
					<!-- <a class="gold-button" href="">Share This Project</a> -->
				  <a class="gold-button" href="">Get a Quote</a>
				  <a class="gold-button" href="">Leave a Review</a>
				  <a class="gold-button" href="<?php 
            echo wp_get_attachment_image_url($image, 'full');
            ?>
" target="_blank">View Larger Size</a>
				</div>
			<?php 
        }
        ?>
			<?php 
    }
    //end regular loop
    ?>
		
		<?php 
}
//end acf conditional featured_at_top
?>
开发者ID:RCMmedia,项目名称:kuopp,代码行数:31,代码来源:single-project.php

示例13: get_site_icon_url

function get_site_icon_url($size = 512, $url = '', $blog_id = 0)
{
    if (is_multisite() && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
    }
    $site_icon_id = get_option('site_icon');
    if ($site_icon_id) {
        if ($size >= 512) {
            $size_data = 'full';
        } else {
            $size_data = array($size, $size);
        }
        $url = wp_get_attachment_image_url($site_icon_id, $size_data);
    }
    if (is_multisite() && ms_is_switched()) {
        restore_current_blog();
    }
    return apply_filters('get_site_icon_url', $url, $size, $blog_id);
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:19,代码来源:general-template.php

示例14: getUrl

 public function getUrl($size)
 {
     return wp_get_attachment_image_url($this->id, $size);
 }
开发者ID:alpineio,项目名称:atlas,代码行数:4,代码来源:PhotoFieldType.php

示例15: json_decode

				<?php 
    $arr = json_decode(stripslashes(Cookie::get('basket')), true, 4);
    foreach ($arr as $k => $prod) {
        $priceProd = 0;
        $countProd = 0;
        foreach ($prod as $p) {
            $priceProd += $p['count'] * $p['price'];
            $countProd += $p['count'];
        }
        ?>
				<!-- open .basket__box--line -->
				<div class="basket__box--line">
					<!-- open .basket__box--thumb -->
					<div class="basket__box--thumb">
						<img src="<?php 
        echo wp_get_attachment_image_url(get_post_thumbnail_id($k));
        ?>
" alt="" />
					</div>
					<!-- close .basket__box--thumb -->
					<!-- open .basket__box--info -->
					<div class="basket__box--info">
						<!-- open .basket__box--info--name -->
						<div class="basket__box--info--name"><?php 
        echo $prod[0]['title'];
        ?>
</div>
						<!-- close .basket__box--info--name -->
						<!-- open .basket__box--info--count -->
						<div class="basket__box--info--count"><?php 
        echo $countProd;
开发者ID:Kirbaba,项目名称:Lic-company,代码行数:31,代码来源:page-basket.php


注:本文中的wp_get_attachment_image_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。