PHP - Image resizing class in wordpress -


i have created function resizing wordpress image based on

http://www.hashbangcode.com/blog/create-images-thumbnails-and-cache-them-php-287.html

but getting error:

fatal error: cannot redeclare class image_resize 

but have not called class befor.

here function

function resize_image($thumb_id){         //check thumbnail cache if not create     $attachment = wp_get_attachment_image_src($thumb_id, 'large');     $image_url = pathinfo($attachment[0]);      if (file_exists(get_template_directory().'/images/thumbs/' . $image_url['basename'])) {       // 2592000 = 30 days       if ( time() - filemtime(get_template_directory().'/images/thumbs/'.$image_url['basename']) > 2592000 ) {         unlink(get_template_directory().'/images/thumbs/'.$image_url['basename']);       }     }     if (!file_exists(get_template_directory().'/images/thumbs/' . $image_url['basename'])) {       include(get_template_directory().'/inc/image_resize.php');       // if cache file not exist create it.       $originalimage = new imageresize($attachment[0]);       $originalimage->size_width(120);       $originalimage->save(get_template_directory().'/images/thumbs/'.$image_url['basename']);     } } 

please tell me whats wrong ??

you including image_resize.php has been included before. therefore try execute imageresizeclass declaration 2 times, error get.

replace include include once , take time read documentation , means.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -