Hello David!
I think I have a VERY simple question [dont worry, I will not be asking you "how should I save the pics to my server" :) - my question is right at the bottom...]
Ok here is the full story, perhaps it will be useful to someone else...
The problem:
Some of the images in my feeds have a non cubic sizes such as 8px by 300 px and if I want to display a thumbnail using <img width=100px does not work because it resizes both the width and height of the image and with image sizes such as above I get a VERY long or wide image.
The perfect solution (as David suggested) would be to contact the merchant asking him to correct the images, but since my website is new, and I dont have any sales yet I doubt they will do anything about it... So instead I tried a few of my own solutions and from what it appears the best one is to just import all the product images to the sites server and than run an external script to resize the images to the wanted values and than just fetch them without the width or height image tags.
To do that open your includes/admin.php and at the very top past:
function cacheFetch($url,$iname)
{
$cacheDir = "../productimages/";
$ext = strrchr($url, ".");
$filename = $cacheDir.$iname.$ext;
if (!file_exists('../productimages/'.$filename))
{
exec("wget -N -O ".$filename." \"".$url."\"",$output,$error);
if ($error)
{
$urlb = 'http://www.URL-TO-YOUR-NO-PIC-IMAGE.jpg';
exec("wget -N -O ".$filename." \"".$urlb."\"",$output,$error);
}
}
}
Than (in the same file) find:
/* create dupe_hash value */
$dupe_key = $admin_importFeed["merchant"];
// uncomment any additional fields that you wish to filter duplicates on (description not recommended)
$dupe_key .= strtolower($record[$admin_importFeed["field_name"]]);
// $dupe_key .= $record[$admin_importFeed["field_description"]];
// $dupe_key .= $record[$admin_importFeed["field_image_url"]];
// $dupe_key .= $record[$admin_importFeed["field_buy_url"]];
// $dupe_key .= $record[$admin_importFeed["field_price"]];
$dupe_hash = md5($dupe_key);
and right after add:
$src = $record[$admin_importFeed["field_image_url"]];
$picn = $dupe_hash;
$img = cacheFetch($src, $picn);
Thats it, now just add a folder "productimages" and CHMOD it to 777 and re-import your feeds.
NOTE that with this addition import will take considerably longer time as the script saves all the images.
Now to my question:
when I run the import I see something like the code below in my SSH window:
--16:39:08-- http://www.xxxxxx.com/images/uploads/3008_2383_large.jpg
=> `../images/xxxxxxxx.jpg'
Resolving www.xxxxxx.com... 67.220.109.185
Connecting to www.xxxxxx.com|67.220.109.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11,650 (11K) [image/jpeg]
100%[====================================>] 11,650 --.--K/s
16:39:08 (359.90 KB/s) - `../images/xxxxxxxxxx.jpg' saved [11650/11650]
And that is for every image, so my screen just blinks really fast! - I am sorry for the ignorance but I have no knowledge of SSH what so ever, and my question - is there a way NOT to display this info for every image??
Thanks a lot in advance and Cheers!
Pasha
Hi Pasha,
Sure - as part of the exec statement you can redirect the output to /dev/null, so instead of:
exec("wget -N -O ".$filename." \"".$url."\"",$output,$error);
use:
exec("wget -N -O ".$filename." \"".$url."\" > /dev/null",$output,$error);
(there is probably another way by adding a silent option to wget, but this should work just as well)
Cheers,
David.