本文整理汇总了PHP中wpgrade::option_image_src方法的典型用法代码示例。如果您正苦于以下问题:PHP wpgrade::option_image_src方法的具体用法?PHP wpgrade::option_image_src怎么用?PHP wpgrade::option_image_src使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpgrade
的用法示例。
在下文中一共展示了wpgrade::option_image_src方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpgrade_get_socialimage
function wpgrade_get_socialimage()
{
global $post;
if (!empty($post)) {
$src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '', '');
//we use the featured-classic image id defined
if (has_post_thumbnail($post->ID)) {
$socialimg = $src[0];
} elseif (is_front_page() && wpgrade::option_image_src('main_logo')) {
//if this is the front page we get the logo if no featured-classic image is assigned
$socialimg = wpgrade::option_image_src('main_logo');
} else {
// ! has_post_thumbnail and no front page
$socialimg = '';
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
if (array_key_exists(1, $matches) && array_key_exists(0, $matches[1])) {
$socialimg = $matches[1][0];
}
}
if (empty($socialimg)) {
if (is_attachment()) {
$temp = wp_get_attachment_image_src($post->ID, "full");
$socialimg = $temp[0];
} else {
// ! is_attachement
// try to get the first attached image
$files = get_children('post_parent=' . $post->ID . '&post_type=attachment&post_mime_type=image&order=desc');
if ($files) {
$keys = array_reverse(array_keys($files));
$j = 0;
$num = $keys[$j];
$image = wp_get_attachment_image($num, 'full', true);
$imagepieces = explode('"', $image);
$imagepath = $imagepieces[1];
$socialimg = wp_get_attachment_url($num);
} else {
// ! $files (use a default image)
// check if we have one uploaded in the theme options
if (wpgrade::option_image_src('social_share_default_image')) {
$socialimg = wpgrade::option_image_src('social_share_default_image');
} else {
// ! social_share_default_image (use the default thumb gif)
$socialimg = wpgrade::uri('/assets/images/nothumb.png');
}
}
}
}
return $socialimg;
} else {
// empty $post
return '';
}
}