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


PHP get_attachment_innerHTML函数代码示例

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


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

示例1: get_the_attachment_link

/**
 * Retrieve HTML content of attachment image with link.
 *
 * @since 2.0.0
 * @deprecated 2.5.0
 * @deprecated Use wp_get_attachment_link()
 * @see wp_get_attachment_link()
 *
 * @param int $id Optional. Post ID.
 * @param bool $fullsize Optional, default is false. Whether to use full size image.
 * @param array $max_dims Optional. Max image dimensions.
 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
 * @return string
 */
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false)
{
    _deprecated_function(__FUNCTION__, '2.5', 'wp_get_attachment_link()');
    $id = (int) $id;
    $_post = get_post($id);
    if ('attachment' != $_post->post_type || !($url = wp_get_attachment_url($_post->ID))) {
        return __('Missing Attachment');
    }
    if ($permalink) {
        $url = get_attachment_link($_post->ID);
    }
    $post_title = esc_attr($_post->post_title);
    $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
    return "<a href='{$url}' title='{$post_title}'>{$innerHTML}</a>";
}
开发者ID:rkglug,项目名称:WordPress,代码行数:29,代码来源:deprecated.php

示例2: get_the_attachment_link

function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false)
{
    $id = (int) $id;
    $_post =& get_post($id);
    if ('attachment' != $_post->post_type || !($url = wp_get_attachment_url($_post->ID))) {
        return __('Missing Attachment');
    }
    if ($permalink) {
        $url = get_attachment_link($_post->ID);
    }
    $post_title = attribute_escape($_post->post_title);
    $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
    return "<a href='{$url}' title='{$post_title}'>{$innerHTML}</a>";
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:14,代码来源:post-template.php

示例3: wp_upload_display

function wp_upload_display( $dims = false, $href = '' ) {
	global $post;
	$id = get_the_ID();
	$attachment_data = wp_get_attachment_metadata( $id );
	$is_image = (int) wp_attachment_is_image();
	if ( !isset($attachment_data['width']) && $is_image ) {
		if ( $image_data = getimagesize( get_attached_file( $id ) ) ) {
			$attachment_data['width'] = $image_data[0];
			$attachment_data['height'] = $image_data[1];
			wp_update_attachment_metadata( $id, $attachment_data );
		}
	}
	if ( isset($attachment_data['width']) )
		list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);

	ob_start();
		the_title();
		$post_title = attribute_escape(ob_get_contents());
	ob_end_clean();
	$post_content = attribute_escape(apply_filters( 'content_edit_pre', $post->post_content ));

	$class = 'text';
	$innerHTML = get_attachment_innerHTML( $id, false, $dims );
	if ( $image_src = get_attachment_icon_src() ) {
		$image_rel = wp_make_link_relative($image_src);
		$innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
		$class = 'image';
	}

	$src_base = wp_get_attachment_url();
	$src = wp_make_link_relative( $src_base );
	$src_base = str_replace($src, '', $src_base);

	$r = '';

	if ( $href )
		$r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n";
	if ( $href || $image_src )
		$r .= "\t\t\t$innerHTML";
	if ( $href )
		$r .= "</a>\n";
	$r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
	$r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
	$r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";

	if ( !$thumb_base = wp_get_attachment_thumb_url() )
		$thumb_base = wp_mime_type_icon();
	if ( $thumb_base ) {
		$thumb_rel = wp_make_link_relative( $thumb_base );
		$thumb_base = str_replace( $thumb_rel, '', $thumb_base );
		$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_rel' />\n";
		$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$thumb_base' />\n";
	}

	$r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='$is_image' />\n";

	if ( isset($width) ) {
		$r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
		$r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";
	}
	$r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-$id' id='attachment-page-url-$id' value='" . get_attachment_link( $id ) . "' />\n";
	$r .= "\t\t\t\t<input type='hidden' name='attachment-title-$id' id='attachment-title-$id' value='$post_title' />\n";
	$r .= "\t\t\t\t<input type='hidden' name='attachment-description-$id' id='attachment-description-$id' value='$post_content' />\n";
	$r .= "\t\t\t</p>\n\t\t</div>\n";
	return $r;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:66,代码来源:upload-functions.php

示例4: wp_upload_display

function wp_upload_display($dims = false, $href = '')
{
    global $post;
    $id = get_the_ID();
    $attachment_data = wp_get_attachment_metadata($id);
    $is_image = (int) wp_attachment_is_image();
    $filesystem_path = get_attached_file($id);
    if (!isset($attachment_data['width']) && $is_image) {
        if ($image_data = getimagesize($filesystem_path)) {
            $attachment_data['width'] = $image_data[0];
            $attachment_data['height'] = $image_data[1];
            wp_update_attachment_metadata($id, $attachment_data);
        }
    }
    if (isset($attachment_data['width'])) {
        list($width, $height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
    }
    $post_title = attribute_escape(the_title('', '', false));
    $post_content = attribute_escape(apply_filters('content_edit_pre', $post->post_content));
    $class = 'text';
    $innerHTML = get_attachment_innerHTML($id, false, $dims);
    if ($image_src = get_attachment_icon_src()) {
        $image_rel = wp_make_link_relative($image_src);
        $innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
        $class = 'image';
    }
    $src_base = wp_get_attachment_url();
    $src = wp_make_link_relative($src_base);
    $src_base = str_replace($src, '', $src_base);
    if (!trim($post_title)) {
        $post_title = basename($src);
    }
    $r = '';
    if ($href) {
        $r .= "<a id='file-link-{$id}' href='{$href}' title='{$post_title}' class='file-link {$class}'>\n";
    }
    if ($href || $image_src) {
        $r .= "\t\t\t{$innerHTML}";
    }
    if ($href) {
        $r .= "</a>\n";
    }
    $size = @filesize($filesystem_path);
    if (!empty($size)) {
        $r .= "\t\t\t\t<span class='upload-file-size'>" . size_format($size) . "</span>\n";
    }
    $r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-{$id}' id='attachment-url-{$id}' value='{$src}' />\n";
    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-{$id}' id='attachment-url-base-{$id}' value='{$src_base}' />\n";
    if (!($thumb_base = wp_get_attachment_thumb_url())) {
        $thumb_base = wp_mime_type_icon();
    }
    if ($thumb_base) {
        $thumb_rel = wp_make_link_relative($thumb_base);
        $thumb_base = str_replace($thumb_rel, '', $thumb_base);
        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-{$id}' id='attachment-thumb-url-{$id}' value='{$thumb_rel}' />\n";
        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-{$id}' id='attachment-thumb-url-base-{$id}' value='{$thumb_base}' />\n";
    }
    $r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-{$id}' id='attachment-is-image-{$id}' value='{$is_image}' />\n";
    if (isset($width)) {
        $r .= "\t\t\t\t<input type='hidden' name='attachment-width-{$id}' id='attachment-width-{$id}' value='{$width}' />\n";
        $r .= "\t\t\t\t<input type='hidden' name='attachment-height-{$id}' id='attachment-height-{$id}' value='{$height}' />\n";
    }
    $r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-{$id}' id='attachment-page-url-{$id}' value='" . get_attachment_link($id) . "' />\n";
    $r .= "\t\t\t\t<input type='hidden' name='attachment-title-{$id}' id='attachment-title-{$id}' value='{$post_title}' />\n";
    $r .= "\t\t\t\t<input type='hidden' name='attachment-description-{$id}' id='attachment-description-{$id}' value='{$post_content}' />\n";
    $r .= "\t\t\t</p>\n\t\t</div>\n";
    return $r;
}
开发者ID:nurpax,项目名称:saastafi,代码行数:69,代码来源:upload.php

示例5: get_the_attachment_link

function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false) {
	$id = (int) $id;
	$_post = & get_post($id);

	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url() )
		return __('Missing Attachment');

	$post_title = attribute_escape($_post->post_title);

	$innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
	return "<a href='$url' title='$post_title'>$innerHTML</a>";
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:12,代码来源:post-template.php

示例6: get_the_attachment_link

function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false)
{
    $id = (int) $id;
    $_post =& get_post($id);
    if ('attachment' != $_post->post_status || '' == $_post->guid) {
        return __('Missing Attachment');
    }
    if (!empty($_post->guid)) {
        $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
        return "<a href=\"{$_post->guid}\" title=\"{$_post->post_title}\" >{$innerHTML}</a>";
    } else {
        $p .= __('Missing attachment');
    }
    return $p;
}
开发者ID:robertlange81,项目名称:Website,代码行数:15,代码来源:template-functions-post.php


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