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

Retrieve URL for an image associated with the post


Description Description

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.


Top ↑

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.8.0 Unknown.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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