syamilmj / Aqua-Resizer

Resize WordPress images on the fly
502 stars 205 forks source link

Aq_Resize.process() error #105

Open bladecold opened 6 years ago

bladecold commented 6 years ago

Hi,

error.log detail

fix error please.

Aq_Resize.process() error: $url parameter is required Aq_Resize.process() error: $url parameter is required Aq_Resize.process() error: $url parameter is required Aq_Resize.process() error: $url parameter is required

example:

$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url($thumb,'full' ); 
$image = aq_resize( $img_url, 156, 104, true,true,true ); 
if ( has_post_thumbnail() ) { ?> 
   <img src="<?php echo $image ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" style="display: inline;" width="156" height="104" /> 
awps commented 6 years ago

From this error results that $img_url is empty. You should process an image only if a valid image url exists:

$thumb  = get_post_thumbnail_id();
$img_url = wp_get_attachment_url($thumb,'full' ); 
if ( ! empty( $img_url ) && has_post_thumbnail() ) : //Just to be safe
    $image = aq_resize( $img_url, 156, 104, true,true,true ); 
?> 
   <img src="<?php echo $image ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" style="display: inline;" width="156" height="104" /> 
<?php 
endif;
tradesouthwest commented 5 years ago

I had a theme using Aq_Resize and had to tell it the $url was empty in the theme's callback. Originally they had the final as:

`if(!function_exists('aq_resize')) { /**

And I simply added a string value of '' nada and all the errors went bye bye.

`if(!function_exists('aq_resize')) { /**