Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jonohlsson

    (@jonohlsson)

    Fantastic. Thanks!

    But for some reason the $content array only held an integer, not the image object. So I had to do an ugly workaround:

    add_filter( 'meta_field_block_get_block_content', function ( $content,$attributes, $block, $post_id ) { 
      $field_name = $attributes['fieldName'] ?? ''; 
       if ('your_image_field' === $field_name) { 
        $url = get_field( 'your_url_field', $post_id ); 
        $image = get_field( 'your_image_field', $post_id );
        if ( esc_url($url) ) {
        $content = sprintf( '<a href="%1$s"><img src="%2$s"></a>', esc_url( $url ), $image ); 
        } 
       } 
    return $content; }, 10, 4 );

    When I added a standard Meta field block for only the image it was rendered correctly.

    Thread Starter jonohlsson

    (@jonohlsson)

    Note

    <?php if ( current_theme_supports( "post-thumbnails" ) && isset( $instance["thumb"] ) && has_post_thumbnail() ) : ?>
    					<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    						<?php the_post_thumbnail( 'latest_posts_thumb_size' . $this->id ); ?>
    					</a>
    				<?php endif; ?>

    is now above the post-title section.

Viewing 2 replies - 1 through 2 (of 2 total)