PHP 클래스 Jetpack_PostImages, jetpack

Includes a few different methods, all of which return a similar-format array containing details of any images found. Everything can (should) be called statically, it's just a function-bucket. You can also call Jetpack_PostImages::get_image() to cycle through all of the methods until one of them finds something useful. This file is included verbatim in Jetpack
파일 보기 프로젝트 열기: automattic/jetpack 1 사용 예제들

공개 메소드들

메소드 설명
fit_image_url ( string $src, $width, $height ) : string Takes an image URL and pixel dimensions then returns a URL for the resized and croped image.
from_attachment ( $post_id, $width = 200, $height = 200 ) Get attachment images for a specified post and return them. Also make sure their dimensions are at or above a required minimum.
from_blavatar ( integer $post_id, integer $size = 96 ) : Array
from_gallery ( $post_id ) If a gallery is detected, then get all the images from it.
from_gravatar ( integer $post_id, integer $size = 96, string $default = false ) : Array
from_html ( mixed $html_or_id ) : Array Very raw -- just parse the HTML and pull out any/all img tags and return their src
from_slideshow ( $post_id, $width = 200, $height = 200 ) If a slideshow is embedded within a post, then parse out the images involved and return them
from_thumbnail ( integer $post_id, $width = 200, $height = 200 ) : Array Check if a Featured Image is set for this post, and return it in a similar format to the other images?_from_*() methods.
get_image ( integer $post_id, array $args = [] ) : Array Run through the different methods that we have available to try to find a single good display image for this post.
get_images ( integer $post_id, array $args = [] ) : Array Get an array containing a collection of possible images for this post, stopping once we hit a method that returns something useful.

메소드 상세

fit_image_url() 정적인 공개 메소드

Takes an image URL and pixel dimensions then returns a URL for the resized and croped image.
static public fit_image_url ( string $src, $width, $height ) : string
$src string
리턴 string Transformed image URL

from_attachment() 정적인 공개 메소드

Get attachment images for a specified post and return them. Also make sure their dimensions are at or above a required minimum.
static public from_attachment ( $post_id, $width = 200, $height = 200 )

from_blavatar() 정적인 공개 메소드

static public from_blavatar ( integer $post_id, integer $size = 96 ) : Array
$post_id integer The post ID to check
$size integer
리턴 Array containing details of the image, or empty array if none.

from_gravatar() 정적인 공개 메소드

static public from_gravatar ( integer $post_id, integer $size = 96, string $default = false ) : Array
$post_id integer The post ID to check
$size integer
$default string The default image to use.
리턴 Array containing details of the image, or empty array if none.

from_html() 정적인 공개 메소드

Very raw -- just parse the HTML and pull out any/all img tags and return their src
static public from_html ( mixed $html_or_id ) : Array
$html_or_id mixed The HTML string to parse for images, or a post id
리턴 Array containing images

from_slideshow() 정적인 공개 메소드

If a slideshow is embedded within a post, then parse out the images involved and return them
static public from_slideshow ( $post_id, $width = 200, $height = 200 )

from_thumbnail() 정적인 공개 메소드

Check if a Featured Image is set for this post, and return it in a similar format to the other images?_from_*() methods.
static public from_thumbnail ( integer $post_id, $width = 200, $height = 200 ) : Array
$post_id integer The post ID to check
리턴 Array containing details of the Featured Image, or empty array if none.

get_image() 정적인 공개 메소드

Run through the different methods that we have available to try to find a single good display image for this post.
static public get_image ( integer $post_id, array $args = [] ) : Array
$post_id integer
$args array Other arguments (currently width and height required for images where possible to determine)
리턴 Array containing details of the best image to be used

get_images() 정적인 공개 메소드

Get an array containing a collection of possible images for this post, stopping once we hit a method that returns something useful.
static public get_images ( integer $post_id, array $args = [] ) : Array
$post_id integer
$args array Optional args, see defaults list for details
리턴 Array containing images that would be good for representing this post