• Resolved jinyus

    (@jinyus)


    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), $args['size'] );
    
    	$use_ellipsis = false;
    
    	if ( is_array( $thumb ) ) {
    		$thumb_width  = absint( $thumb[1] );
    		$thumb_height = absint( $thumb[2] );
    
    		// Use ellipsis.
    		if ( $args['use_ellipsis'] ) {
    			$ratio = 0 !== $thumb_width ? $thumb_height / $thumb_width : 0;
    			$use_ellipsis = $ratio > ( 3 / 1 ) ? true : false;
    		}
    
    		// Use sizer. Prevent image loading jump.
    		if ( true === $args['use_sizer'] ) {
    			$inner_style_escaped = ' style="padding-bottom: ' . sprintf( "%.8F", $thumb[2] / $thumb[1] * 100   ) . '%;"';
    		}
    		
    	}

    “$thumb[2] / $thumb[1] * 100” this line returns a division by 0 error.
    I think this error is there because the width of the external image is set to auto, can you help me correct this.

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

The topic ‘Division by 0 error’ is closed to new replies.