LLMS_Post_Model::get_image( string|array $size = 'full', string $key = '' )

Retrieve URL for an image associated with the post Currently only retrieves the featured image if the post type supports it in the future this will allow retrieval of custom post images as well


Description Description


Parameters Parameters

$size

(string|array) (Optional) registered image size or a numeric array with width/height

Default value: 'full'

$key

(string) (Optional) currently unused but here for forward compatibility if additional custom images are added

Default value: ''


Top ↑

Return Return

(string) empty string if no image or not supported


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	public function get_image( $size = 'full', $key = '' ) {
		if ( 'thumbnail' === $key && post_type_supports( $this->db_post_type, 'thumbnail' ) ) {
			$url = get_the_post_thumbnail_url( $this->get( 'id' ), $size );
		} else {
			$id = $this->get( $key );
			if ( is_numeric( $id ) ) {
				$src = wp_get_attachment_image_src( $id, $size );
				if ( $src ) {
					$url = $src[0];
				}
			}
		}
		return ! empty( $url ) ? $url : '';
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: