I'm trying to post products from shop pages or individually to Pinterest. I now get a "This is not a valid image." or "Can't save this page." message and can't post. I checked, and had posted cached images before w/out an issue. The only thing I've changed is that my site is now https. What am I doing wrong or need to change?
Ack, that was the issue, no .jpg extension, for example, the long {link saved}. I must have pinned the images before they cached somehow. OK, will make that change first.
Hi,
To give this a go, first add the following new rule to the end of .htaccess
RewriteRule ^cimages/(.*).jpg$ imageCache.php?src=$1 [B,L]
And then to convert for Featured Products; look for the following code for the src attribute of the img tag at line 17 of html/featured.php:
src='<?php print $config_baseHREF."imageCache.php?src=".base64_encode($product["image_url"]); ?>'
...and REPLACE with:
src='<?php print $config_baseHREF."cimages/".base64_encode($product["image_url"]).".jpg"; ?>'
For Search Results, look for the following code for the src attribute of the img tag at line 19 of html/searchresults.php:
src='<?php print $config_baseHREF."imageCache.php?src=".base64_encode($product["image_url"]); ?>'
...and REPLACE with:
src='<?php print $config_baseHREF."cimages/".base64_encode($product["image_url"]).".jpg"; ?>'
And for the main product image, look for the following code for the src attribute of the img tag at line 32 of html/product.php:
src='<?php print $config_baseHREF."imageCache.php?src=".base64_encode($product_main["image_url"]); ?>'
...and REPLACE with:
src='<?php print $config_baseHREF."cimages/".base64_encode($product_main["image_url"]).".jpg"; ?>'
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi David,
Didn't have a chance to try until now. No joy.
Still can't use B flag in htaccess, but worked without.
The replacement code didn't work, but when I added .".jpg" to the original code: ($product_main["image_url"]).".jpg"; ?>' .jpg extension was added to URL.
However, Pinterest still won't post image. All search results/feature page images disappeared, yet many appeared on the product page, which is where I attempted to post to Pinterest.
I reverted back to original to display images again.
Hi,
If you would like to email me currently with working images html/product.php (I think you mentioned not using cached images at the moment) and also .htaccess and latest imageCache.php I'll check it out further with you...
Cheers,
David.
--
PriceTapestry.com
Hi David
Just implementing this atm
is it possible to use normalised name when using this method?
Thanks
Phil
Hello Phil,
Sure - with the same new RewriteRule in place as above, edit imageCache.php and look for the following code at line 91:
$src = base64_decode($_GET["src"]);
...and REPLACE with:
$src = tapestry_normalise($_GET["src"]);
$sql = "SELECT image_url FROM `".$config_databaseTablePrefix."products` WHERE normalised_name='".database_safe($src)."' AND image_url <> '' LIMIT 1";
if (!database_querySelect($sql,$rows))
{
header("HTTP/1.0 404 Not Found");
exit();
}
$src = $rows[0]["image_url"];
And then as the <img ...> src attribute in html/featured.php
src='<?php print $config_baseHREF."cimages/".tapestry_hyphenate($product["normalised_name"]).".jpg"; ?>'
...and for html/searchresults.php
src='<?php print $config_baseHREF."cimages/".tapestry_hyphenate($product["normalised_name"]).".jpg"; ?>'
...and for html/product.php
src='<?php print $config_baseHREF."cimages/".tapestry_hyphenate($product_main["normalised_name"]).".jpg"; ?>'
Cheers,
David.
--
PriceTapestry.com
Hi David
This is working perfectly, although there is now a delay in loading the image? not sure why
here is my imageCache.php code:
{code saved}
would be grateful if You could check it for me. Thanks!
Phil
Hi David
Also just realising if the the image is coming from Amazon / eBay or Kelkoo api how do i get it to use that image and not look in the database?
Thanks
Phil
Hi Phil,
I checked your site and images seem to be loading fine - the speed may just have been temporary as moving to passing by normalised_name may mean a different image selected for some products which would then need to be fetched for the first time.
Regarding API images, the relevant $product / $product_main records should be absent of any `id` field so have a go with the following for html/searchresults.php
src='<?php print (isset($product["id"])?$config_baseHREF."cimages/".tapestry_hyphenate($product["normalised_name"]).".jpg":$product["image_url"]); ?>'
...and for html/product.php
src='<?php print (isset($product_main["id"])?$config_baseHREF."cimages/".tapestry_hyphenate($product_main["normalised_name"]).".jpg":$product_main["image_url"]); ?>'
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Thanks David
Working perfect on searchresults.php page but on the products page the image it's loading but the url for non api is coming up as the image_url from database? not sure why?
Thanks
Phil
Hi Phil,
Sorry about that - isset() check in html/product.php should have used $product_main - corrected above...
Cheers,
David.
--
PriceTapestry.com
Hi,
If cached images have been working with Pintrest previously I can't see why changing to https should have any impact; unless something has changed at Pintrest and for some reason it doesn't like the image URL not ending in any standard image extension. I checked the latest imageCache.php that I have from you in email and it is definitely sending the correct content-type header;
header("Content-Type: image/jpeg");
If you could perhaps post an example image URL (I'll remove before posting your reply) I'll fetch it to check everyhing looks OK however it is possible to rewrite cached image URLs for example instead of;
/imageCache.php?src={BASE64_ENCODED_IMAGE_URL}
...into
/cimages/{BASE64_ENCODED_IMAGE_URL}.jpg
Cheers,
David.
--
PriceTapestry.com