/** * Returns the img tag for the given product image * * @param string $image The name of the imahe OR the full URL to the image * @param string $args Additional attributes for the img tag * @param int $resize * (1 = resize the image by using height and width attributes, * 0 = do not resize the image) * @param string $path_appendix The path to be appended to IMAGEURL / IMAGEPATH * @return The HTML code of the img tag */ function image_tag($image, $args="", $resize=1, $path_appendix='product', $thumb_width=0, $thumb_height=0 ) { global $mosConfig_live_site, $mosConfig_absolute_path; require_once( CLASSPATH . 'imageTools.class.php'); $border=""; if( strpos( $args, "border=" )===false ) { $border = 'border="0"'; } $height = $width = 0; if ($image != "") { // URL if( substr( $image, 0, 4) == "http" ) { $url = $image; } // local image file else { if(PSHOP_IMG_RESIZE_ENABLE == '1' && $resize==1) { $url = $mosConfig_live_site."/components/com_virtuemart/show_image_in_imgtag.php?filename=".urlencode($image)."&newxsize=".PSHOP_IMG_WIDTH."&newysize=".PSHOP_IMG_HEIGHT."&fileout="; if( !strpos( $args, "height=" )) { $arr = @getimagesize( vmImageTools::getresizedfilename( $image, $path_appendix, '', $thumb_height, $thumb_width ) ); $width = $arr[0]; $height = $arr[1]; } } else { $url = IMAGEURL.$path_appendix.'/'.$image; $using_resized_image = false; if( $resize ) { $image = vmImageTools::getresizedfilename( $image, $path_appendix, '', $thumb_height, $thumb_width ); if( file_exists($image)) { $using_resized_image = true; } } if( $resize && ! $using_resized_image) { if( $height < $width ) { $width = @round($width / ($height / PSHOP_IMG_HEIGHT)); $height = PSHOP_IMG_HEIGHT; } else { $height = @round($height / ($width / PSHOP_IMG_WIDTH )); $width = PSHOP_IMG_WIDTH; } } if( file_exists($image)) { $url = str_replace( $mosConfig_absolute_path, $mosConfig_live_site, $image ); } elseif( file_exists($mosConfig_absolute_path.'/'.$image)) { $url = $mosConfig_live_site.'/'.$image; } $url = str_replace('//', '/', $url ); $url = str_replace(':/', '://', $url ); if( !strpos( $args, "height=" ) ) { $f = str_replace( IMAGEURL, IMAGEPATH, $url ); if ( file_exists($f) ) { $arr = getimagesize( $f ); $width = $arr[0]; $height = $arr[1]; } else { $width = 100; $height = 100; } } } $url = str_replace( basename( $url ), $GLOBALS['VM_LANG']->convert(basename($url)), $url ); } } else { $url = VM_THEMEURL.'images/'.NO_IMAGE; } return vmCommonHTML::imageTag( $url, '', '', $height, $width, '', '', $args.' '.$border ); }