You are here:  » Php Code Images


Php Code Images

Submitted by affiliben on Tue, 2014-09-02 11:22 in

Hi David
Sorry to trouble you again.
One of my merchants has changed their feeds and is now in json which thanks to your previous help I can turn into a csv or xml.
However the images are not being sent as jpeg urls but in this format

{s:8:"PHOTO_ID";s:64:"35e5014e59a398fd6f9a2321e8b8138ed26721712ed4a2c9238719a782a7cb8f";
s:15:"PHOTO_PANORAMIC";b:0;s:10:"PHOTO_NAME";s:50:"photo name";s:14:"PHOTO_COMMENTS";s:0:"";s:10:"PHOTO_SIZE";i:65270;}i:1;O:8:"stdClass":5:

is there any way that these type of images ( are they php generated?) can be displayed within Price Tapestry?
My other merchants use standard jpg urls and my situation is further complicated in that I use multiple images (as in one of your other mods but I can't find the page) displayed using a lightbox.

Thanks
Ben

Submitted by support on Tue, 2014-09-02 13:24

Hi Ben,

If i've understood correctly, once you've converted the JSON source into XML for importing, you are left with an Image URL field that is PHP serialized object. That's easily handled with a simple filter, however I notice that the object itself doesn't even contain an image URL so this may need to be reconstructed using an appropriate combination of Text Before / After filters. Firstly, if you add the following code to the end of your includes/filter.php (13/03A) :

  /*************************************************/
  /* unserialize */
  /*************************************************/
  $filter_names["unserialize"] = "Unserialize";
  function filter_unserializeConfigure($filter_data)
  {
    print "Key:<br />";
    print "<input type='text' size='40' name='key' value='".widget_safe($filter_data["key"])."' />";
    widget_errorGet("key");
  }
  function filter_unserializeValidate($filter_data)
  {
    if (!$filter_data["key"])
    {
      widget_errorSet("key","required field");
    }
  }
  function filter_unserializeExec($filter_data,$text)
  {
    $o = unserialize($text);
    return $o->$filter_data["key"];
  }

If you then add a new Unserialize filter to the Image URL field for this feed, and use PHOTO_ID as the key. This will result in an image_url value that is just the PHOTO_ID field from the serialized object.

The next thing you will need to do is find out from the affiliate network or feed / API documentation how to use this to construct the image URL, for example it might be something like:

http://www.example.com/images/[PHOTO_ID].jpg

This can be constructed by subsequently adding a Text Before filter containing:

http://www.example.com/images/

...and a Text After filter of:

.jpg

Regarding help with a shopping list crossing multiple installation, could you perhaps email me links to a couple of the sub-installations that you want to implement this on and I'll check it out for you...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com