update_post_thumbnail_cache example

if ( isset( $attributes['categories'] ) ) {
        $args['category__in'] = array_column( $attributes['categories'], 'id' );
    }
    if ( isset( $attributes['selectedAuthor'] ) ) {
        $args['author'] = $attributes['selectedAuthor'];
    }

    $query        = new WP_Query();
    $recent_posts = $query->query( $args );

    if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) {
        update_post_thumbnail_cache( $query );
    }

    $list_items_markup = '';

    foreach ( $recent_posts as $post ) {
        $post_link = esc_url( get_permalink( $post ) );
        $title     = get_the_title( $post );

        if ( ! $title ) {
            $title = __( '(no title)' );
        }

        
$this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter'];

        $this->set_pagination_args(
            array(
                'total_items' => $wp_query->found_posts,
                'total_pages' => $wp_query->max_num_pages,
                'per_page'    => $wp_query->query_vars['posts_per_page'],
            )
        );
        if ( $wp_query->posts ) {
            update_post_thumbnail_cache( $wp_query );
            update_post_parent_caches( $wp_query->posts );
        }
    }

    /** * @global array $post_mime_types * @global array $avail_post_mime_types * @return array */
    protected function get_views() {
        global $post_mime_types$avail_post_mime_types;

        

        do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id$size );

        if ( in_the_loop() ) {
            update_post_thumbnail_cache();
        }

        $html = wp_get_attachment_image( $post_thumbnail_id$size, false, $attr );

        /** * Fires after fetching the post thumbnail HTML. * * @since 2.9.0 * * @param int $post_id The post ID. * @param int $post_thumbnail_id The post thumbnail ID. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels (in that order). */
/* * Inserts the featured image between the (1st) cover 'background' `span` and 'inner_container' `div`, * and removes eventual whitespace characters between the two (typically introduced at template level) */
        $inner_container_start = '/<div\b[^>]+wp-block-cover__inner-container[\s|"][^>]*>/U';
        if ( 1 === preg_match( $inner_container_start$content$matches, PREG_OFFSET_CAPTURE ) ) {
            $offset  = $matches[0][1];
            $content = substr( $content, 0, $offset ) . $image . substr( $content$offset );
        }
    } else {
        if ( in_the_loop() ) {
            update_post_thumbnail_cache();
        }
        $current_featured_image = get_the_post_thumbnail_url();
        if ( ! $current_featured_image ) {
            return $content;
        }

        $processor = new WP_HTML_Tag_Processor( $content );
        $processor->next_tag();

        $styles         = $processor->get_attribute( 'style' );
        $merged_styles  = ! empty( $styles ) ? $styles . ';' : '';
        
// Allow access to all password protected posts if the context is edit.         if ( 'edit' === $request['context'] ) {
            add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );
        }

        $posts = array();

        update_post_author_caches( $query_result );
        update_post_parent_caches( $query_result );

        if ( post_type_supports( $this->post_type, 'thumbnail' ) ) {
            update_post_thumbnail_cache( $posts_query );
        }

        foreach ( $query_result as $post ) {
            if ( ! $this->check_read_permission( $post ) ) {
                continue;
            }

            $data    = $this->prepare_item_for_response( $post$request );
            $posts[] = $this->prepare_response_for_collection( $data );
        }

        
$query = clone $wp_query;
    } else {
        $query_args = build_query_vars_from_query_block( $block$page );
        $query      = new WP_Query( $query_args );
    }

    if ( ! $query->have_posts() ) {
        return '';
    }

    if ( block_core_post_template_uses_featured_image( $block->inner_blocks ) ) {
        update_post_thumbnail_cache( $query );
    }

    $classnames = '';
    if ( isset( $block->context['displayLayout'] ) && isset( $block->context['query'] ) ) {
        if ( isset( $block->context['displayLayout']['type'] ) && 'flex' === $block->context['displayLayout']['type'] ) {
            $classnames = "is-flex-container columns-{$block->context['displayLayout']['columns']}";
        }
    }
    if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
        $classnames .= ' has-link-color';
    }

    
Home | Imprint | This part of the site doesn't use cookies.