本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: form_field
/**
* Output the form field
*
* @since 0.1.0
*
* @param $term
*/
protected function form_field($term = '')
{
$term_id = !empty($term->term_id) ? $term->term_id : 0;
// Remove image URL
$remove_url = add_query_arg(array('action' => 'remove-wp-term-images', 'term_id' => $term_id, '_wpnonce' => false));
// Get the meta value
$value = $this->get_meta($term_id);
$hidden = empty($value) ? ' style="display: none;"' : '';
?>
<div>
<img id="wp-term-images-photo" src="<?php
echo esc_url(wp_get_attachment_image_url($value, 'full'));
?>
"<?php
echo $hidden;
?>
/>
<input type="hidden" name="term-<?php
echo esc_attr($this->meta_key);
?>
" id="term-<?php
echo esc_attr($this->meta_key);
?>
" value="<?php
echo esc_attr($value);
?>
" />
</div>
<a class="button-secondary wp-term-images-media">
<?php
esc_html_e('Choose Image', 'wp-term-images');
?>
</a>
<a href="<?php
echo esc_url($remove_url);
?>
" class="button wp-term-images-remove"<?php
echo $hidden;
?>
>
<?php
esc_html_e('Remove', 'wp-user-avatars');
?>
</a>
<?php
}
开发者ID:johnbillion,项目名称:wp-term-images,代码行数:57,代码来源:class-wp-term-images.php
示例17: single_post_title
">
<!-- Twitter Cards -->
<meta property="twitter:card" content="summary">
<meta property="twitter:site" content="@sophieuliano">
<meta property="twitter:title" content="<?php
single_post_title('');
?>
">
<meta property="twitter:description" content="<?php
echo strip_tags(get_the_excerpt());
?>
">
<meta property="twitter:creator" content="@sophieuliano">
<meta property="twitter:image" content="<?php
if (function_exists('wp_get_attachment_thumb_url')) {
echo wp_get_attachment_image_url(get_post_thumbnail_id($post->ID), 'medium', false);
}
?>
">
<meta property="twitter:url" content="<?php
the_permalink();
?>
" />
<meta property="twitter:domain" content="<?php
echo site_url();
?>
">
<?php
} else {
?>
<!-- Open Graph -->
开发者ID:Bebeau,项目名称:sophieuliano,代码行数:31,代码来源:header.php
示例18: dunhakdis_team
/**
* Callback function
* @param [type] $atts [description]
* @return [type] [description]
*/
function dunhakdis_team($atts)
{
extract(shortcode_atts(array('avatar' => '', 'name' => '', 'title' => '', 'website' => '', 'facebook' => '', 'googleplus' => '', 'twitter' => '', 'linkedin' => '', 'about' => ''), $atts));
ob_start();
?>
<div class="dunhakdis-team-container">
<?php
if (is_numeric($avatar)) {
?>
<?php
$avatar = wp_get_attachment_image_url(intval($avatar), 'thumbnail');
?>
<?php
}
?>
<?php
if (!empty($avatar)) {
?>
<div class="dunhakdis-team-avatar">
<img class="avatar" src="<?php
echo esc_url($avatar);
?>
" alt="<?php
_e('Profile', 'shoemaker');
?>
">
</div>
<?php
}
?>
<div class="dunhakdis-team-details">
<?php
if (!empty($name)) {
?>
<h3 class="dunhakdis-team-name">
<?php
if (function_exists('vc_build_link')) {
?>
<?php
$website = vc_build_link($website);
?>
<?php
if (is_array($website)) {
?>
<?php
if (!empty($website['url'])) {
?>
<?php
$website = $website['url'];
?>
<?php
}
?>
<?php
}
?>
<?php
}
?>
<?php
if (!empty($website)) {
?>
<a href="<?php
echo esc_url($website);
?>
" title="<?php
echo esc_attr($name);
?>
">
<?php
}
?>
<?php
echo esc_html($name);
?>
<?php
if (!empty($website)) {
?>
</a>
<?php
}
?>
</h3>
//.........这里部分代码省略.........
开发者ID:jasperjardin,项目名称:dunhakdis-utility,代码行数:101,代码来源:team.php
示例19: order_schema_markup
/**
* Adds Schema.org markup for order in JSON-LD format.
*
* @since 2.6.0
* @param mixed $order
* @param bool $sent_to_admin (default: false)
* @param bool $plain_text (default: false)
*/
public function order_schema_markup($order, $sent_to_admin = false, $plain_text = false)
{
if ($plain_text) {
return;
}
$accepted_offers = array();
foreach ($order->get_items() as $item) {
if (!apply_filters('woocommerce_order_item_visible', true, $item)) {
continue;
}
$product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item);
$is_visible = $product && $product->is_visible();
$item_offered = array('@type' => 'Product', 'name' => apply_filters('woocommerce_order_item_name', $item['name'], $item, $is_visible));
if ($sku = $product->get_sku()) {
$item_offered['sku'] = $sku;
}
if ($is_visible) {
$item_offered['url'] = get_permalink($product->get_id());
} else {
$item_offered['url'] = get_home_url();
}
if ($image_id = $product->get_image_id()) {
$item_offered['image'] = wp_get_attachment_image_url($image_id, 'thumbnail');
}
$accepted_offer = (object) array('@type' => 'Offer', 'itemOffered' => $item_offered, 'price' => $order->get_line_subtotal($item), 'priceCurrency' => $order->get_order_currency(), 'eligibleQuantity' => (object) array('@type' => 'QuantitativeValue', 'value' => apply_filters('woocommerce_email_order_item_quantity', $item['qty'], $item)), 'url' => get_home_url());
$accepted_offers[] = $accepted_offer;
}
$markup = array('@context' => 'http://schema.org', '@type' => 'Order', 'merchant' => (object) array('@type' => 'Organization', 'name' => get_bloginfo('name')), 'orderNumber' => strval($order->get_order_number()), 'priceCurrency' => $order->get_order_currency(), 'price' => $order->get_total(), 'acceptedOffer' => count($accepted_offers) > 1 ? $accepted_offers : $accepted_offers[0], 'url' => $order->get_view_order_url());
switch ($order->get_status()) {
case 'pending':
$markup['orderStatus'] = 'http://schema.org/OrderPaymentDue';
break;
case 'processing':
$markup['orderStatus'] = 'http://schema.org/OrderProcessing';
break;
case 'on-hold':
$markup['orderStatus'] = 'http://schema.org/OrderProblem';
break;
case 'completed':
$markup['orderStatus'] = 'http://schema.org/OrderDelivered';
break;
case 'cancelled':
$markup['orderStatus'] = 'http://schema.org/OrderCancelled';
break;
case 'refunded':
$markup['orderStatus'] = 'http://schema.org/OrderReturned';
break;
case 'failed':
$markup['orderStatus'] = 'http://schema.org/OrderProblem';
break;
}
if ($sent_to_admin) {
$markup['potentialAction'] = (object) array('@type' => 'ViewAction', 'target' => admin_url('post.php?post=' . absint($order->id) . '&action=edit'));
}
$markup = apply_filters('woocommerce_email_order_schema_markup', $markup, $sent_to_admin, $order);
echo '<div style="display:none;"><script type="application/ld+json">' . wp_json_encode((object) $markup) . '</script></div>';
}
开发者ID:pcuervo,项目名称:dabba,代码行数:65,代码来源:class-wc-emails.php
示例20: get_theme_mod
}
?>
<?php
$whois_id = 65;
$whois = posts::getPost($whois_id);
if ($whois) {
$twitter_href = get_theme_mod('twitter_href');
$twitter_href = $twitter_href ? $twitter_href : '#';
$google_href = get_theme_mod('google_href');
$google_href = $google_href ? $google_href : '#';
$facebook_href = get_theme_mod('facebook_href');
$facebook_href = $facebook_href ? $facebook_href : '#';
$youtube_href = get_theme_mod('youtube_href');
$youtube_href = $youtube_href ? $youtube_href : '#';
$whois_bg = wp_get_attachment_image_url(get_post_thumbnail_id($whois_id), 'full');
$whois_bg = $whois_bg ? 'background-image: url(' . $whois_bg . ');' : '';
$site_descr = get_bloginfo('description');
?>
<div style="<?php
echo $whois_bg;
?>
" class="container-fluid whois-wrap">
<div class="trans-bg"></div>
<div class="container">
<div class="row">
<div class="col-md-12 header-wrap">
<h2><?php
echo $whois['title'];
?>
</h2>
开发者ID:proger-su,项目名称:slash,代码行数:31,代码来源:index.php
注:本文中的wp_get_attachment_image_url函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论