• Resolved RT_PDX

    (@ronald2020)


    Hi there,

    I am getting many php errors since the release of version 1.5. I was hoping that 1.5.1 would fix it given the changelog comments but it is still there:

    PHP Warning: Trying to access array offset on value of type bool in xxxxxxxxxxxxxx/wp-content/plugins/twentig/inc/blocks.php on line 493′

    Thanks for checking into it.

    R

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Yann

    (@collet)

    Hi,

    Thanks for your feedback. We understand what might cause the issue. Would you please share the URL of your website so we can have a better understanding?

    Thread Starter RT_PDX

    (@ronald2020)

    These errors happen on the backend. I do not show errors on the front end.

    • This reply was modified 2 years ago by RT_PDX.
    Plugin Support Yann

    (@collet)

    We’ve managed to fix the issue, and we’ll release an update later today. In the meantime, only if you’re familiar with editing php file, you can edit the wp-content/plugins/twentig/inc/blocks.php and replace lines 491 to 503

    if ( isset( $attributes['id'] ) ) {
    	$image_meta = wp_get_attachment_metadata( $attributes['id'] );
    	$width      = absint( $image_meta['width'] );
    	if ( $width ) {
    		//cf wp_image_add_srcset_and_sizes()
    		$sizes = sprintf( '(max-width: 799px) 200vw,(max-width: %1$dpx) 100vw,%1$dpx', $width );
    		if ( isset( $attributes['twRatio'] ) ) {
    			$sizes = sprintf( '(max-width: 799px) 125vw,(max-width: %1$dpx) 100vw,%1$dpx', $width );
    		}			
    		$attr          = sprintf( ' sizes="%s"', esc_attr( $sizes ) );
    		$block_content = preg_replace( '/<img ([^>]+?)[\/ ]*>/', '<img $1' . $attr . ' />', $block_content, 1 );
    	}
    }

    by

    if ( isset( $attributes['id'] ) ) {
    	$image_meta = wp_get_attachment_metadata( $attributes['id'] );
    	if ( $image_meta && isset( $image_meta['width'] ) ) {
    		$width = absint( $image_meta['width'] );
    		if ( $width ) {
    			//cf wp_image_add_srcset_and_sizes()
    			$sizes = sprintf( '(max-width: 799px) 200vw,(max-width: %1$dpx) 100vw,%1$dpx', $width );
    			if ( isset( $attributes['twRatio'] ) ) {
    				$sizes = sprintf( '(max-width: 799px) 125vw,(max-width: %1$dpx) 100vw,%1$dpx', $width );
    			}			
    			$attr          = sprintf( ' sizes="%s"', esc_attr( $sizes ) );
    			$block_content = preg_replace( '/<img ([^>]+?)[\/ ]*>/', '<img $1' . $attr . ' />', $block_content, 1 );
    		}
    	}
    }

    Thanks

    Thread Starter RT_PDX

    (@ronald2020)

    Thanks very much !!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Error (since 1.5 and still on 1.51)’ is closed to new replies.