public function get_placeholder_image($post_id, $post_thumbnail_id, $size, $attr = [])
    {
        $original_size = $size;

        $post_id = $post_id ?? \get_the_id();

        if (Image_Utils::get_image_size($size) === false) {
            $size = 'full';
        }

        // Search for a size specific placeholder first.
        $placeholder_url = $this->search_for_placeholder('placeholder-' . $size);

        // Then the post type placeholder.
        if ($placeholder_url === false) {
            $placeholder_url = $this->search_for_placeholder('placeholder-' . get_post_type($post_id));
        }

        // Finally a generic placeholder.
        if ($placeholder_url === false) {
            $placeholder_url = $this->search_for_placeholder('placeholder');
        }

        if ($placeholder_url !== false) {
            $html = \sprintf(
                /** @lang text */
                '<img src="%s" alt="%s" width="%d" height="%d" %s>',
                $placeholder_url,
                get_the_title($post_id),
                \is_array($original_size) ? $original_size[0] : Image_Utils::get_image_width($size),
                \is_array($original_size) ? $original_size[1] : Image_Utils::get_image_height($size),
                $this->parse_attributes($attr)
            );

            /**
             * Filter the placeholder image HTML.
             *
             * @since  1.0.0
             *
             * @param string $output The HTML output for the placeholder image tag.
             * @return string $output The HTML output for the placeholder image tag.
             */
            return \apply_filters('snap_placeholder_img_html', $html);
        }

        return '';
    }
public function get_placeholder_image($post_id, $post_thumbnail_id, $size, $attr = [])
    {
        $original_size = $size;

        $post_id = $post_id ?? \get_the_id();

        if (Image_Utils::get_image_size($size) === false) {
            $size = 'full';
        }

        // Search for a size specific placeholder first.
        $placeholder_url = $this->search_for_placeholder('placeholder-' . $size);

        // Then the post type placeholder.
        if ($placeholder_url === false) {
            $placeholder_url = $this->search_for_placeholder('placeholder-' . get_post_type($post_id));
        }

        // Finally a generic placeholder.
        if ($placeholder_url === false) {
            $placeholder_url = $this->search_for_placeholder('placeholder');
        }

        if ($placeholder_url !== false) {
            $html = \sprintf(
                /** @lang text */
                '<img src="%s" alt="%s" width="%d" height="%d" %s>',
                $placeholder_url,
                get_the_title($post_id),
                \is_array($original_size) ? $original_size[0] : Image_Utils::get_image_width($size),
                \is_array($original_size) ? $original_size[1] : Image_Utils::get_image_height($size),
                $this->parse_attributes($attr)
            );

            /**
             * Filter the placeholder image HTML.
             *
             * @since  1.0.0
             *
             * @param string $output The HTML output for the placeholder image tag.
             * @return string $output The HTML output for the placeholder image tag.
             */
            return \apply_filters('snap_placeholder_img_html', $html);
        }

        return '';
    }
public function get_placeholder_image ( $ post_id , $ post_thumbnail_id , $ size , $ attr = [ ] ) { $ original_size = $ size ; $ post_id = $ post_id ?? \ get_the_id ( ) ; if ( Image_Utils :: get_image_size ( $ size ) === false ) { $ size = 'full' ; } // Search for a size specific placeholder first. $ placeholder_url = $ this -> search_for_placeholder ( 'placeholder-' . $ size ) ; // Then the post type placeholder. if ( $ placeholder_url === false ) { $ placeholder_url = $ this -> search_for_placeholder ( 'placeholder-' . get_post_type ( $ post_id ) ) ; } // Finally a generic placeholder. if ( $ placeholder_url === false ) { $ placeholder_url = $ this -> search_for_placeholder ( 'placeholder' ) ; } if ( $ placeholder_url !== false ) { $ html = \ sprintf ( /** @lang text */ '<img src="%s" alt="%s" width="%d" height="%d" %s>' , $ placeholder_url , get_the_title ( $ post_id ) , \ is_array ( $ original_size ) ? $ original_size [ 0 ] : Image_Utils :: get_image_width ( $ size ) , \ is_array ( $ original_size ) ? $ original_size [ 1 ] : Image_Utils :: get_image_height ( $ size ) , $ this -> parse_attributes ( $ attr ) ) ; /**
             * Filter the placeholder image HTML.
             *
             * @since  1.0.0
             *
             * @param string $output The HTML output for the placeholder image tag.
             * @return string $output The HTML output for the placeholder image tag.
             */ return \ apply_filters ( 'snap_placeholder_img_html' , $ html ) ; } return '' ; }
Searches for a suitable placeholder fallback image.

First checks placeholder-${image_size}, then placeholder-${post_type}, then finally placeholder.

Runs through $this->placeholder_extensions in order when searching for placeholders.

@since 1.0.0

@param  int          $post_id           The post ID.
@param  string       $post_thumbnail_id The post thumbnail ID.
@param  string|array $size              The post thumbnail size. Image size or array of width and height
values (in that order). Default 'post-thumbnail'.
@param  array        $attr              Array string of attributes.
@return string The image HTML
Searches for a suitable placeholder fallback image .