You are here:  » Cached Images Not Valid on Pinterest


Cached Images Not Valid on Pinterest

Submitted by Retro135 on Fri, 2017-12-15 19:42 in

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?

Submitted by support on Mon, 2017-12-18 10:12

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

Submitted by Retro135 on Mon, 2017-12-18 15:26

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.

Submitted by support on Mon, 2017-12-18 16:23

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

Submitted by Retro135 on Mon, 2018-02-12 17:32

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.

Submitted by support on Tue, 2018-02-13 09:14

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

Submitted by philstone on Fri, 2018-03-16 23:49

Hi David

Just implementing this atm

is it possible to use normalised name when using this method?

Thanks

Phil

Submitted by support on Mon, 2018-03-19 09:04

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

Submitted by philstone on Mon, 2018-03-19 10:55

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

Submitted by philstone on Mon, 2018-03-19 11:17

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

Submitted by support on Mon, 2018-03-19 13:31

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

Submitted by philstone on Mon, 2018-03-19 18:57

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

Submitted by support on Mon, 2018-03-19 20:51

Hi Phil,

Sorry about that - isset() check in html/product.php should have used $product_main - corrected above...

Cheers,
David.
--
PriceTapestry.com