marty.net 1001 Postcards Love Love Love Meep Meep ZenZodiac DailyQuotation

YOU ARE HERE:
Extracting CP image URLs from cpshop links

HOME

CPSHOP|

|

|

EMAIL MARTY
  marty.net message board
  « Extracting CP image URLs from cpshop links »
Welcome, Guest. Please Login or Register.
12/11/17 at 13:16:14
Home Help Search Login Register
   marty.net message board
   About cpshop
   Tutorials
   Extracting CP image URLs from cpshop links
(Moderator: Marty)
Pages: 1 Reply Notify of replies Send the topic Print 
   Author  Topic: Extracting CP image URLs from cpshop links  (Read 5779 times)
Hex Angel - Patrick
Gold Dragon
****

Posts: 500



Our nature lies in movement; complete calm is death.
   

WWW
Extracting CP image URLs from cpshop links
« on: 04/04/07 at 18:00:13 »
Reply with quote Modify message

Unless your name is Bradley W. Schenck or Marty you probably don't know a whole lot about CP's naming conventions for image files.  And unless you can at least read and interpret PHP or PERL you probably don't need to. But if you can code at least a little bit then you can do something like this search for love magnets.

Eventually I'll post a tutorial for modifying a search engine to output images as part of its search results, but I haven't decided I'm going with the current one yet.  For now I'll just tell you how to extract CP image file names from cpshop links.

CAVEAT:  From time to time CP changes their image file syntax. This may not work forever, or even past tomorrow.

cpshop generates a few types of links. Two of them contain info we can use.


1. Product Links : Links to product detail pages
2. Section Links : Links to section pages (thumbnail grids)

Product Links

Product Links are easy.  Open your shop in your broswer and go to a product thumbnail grid.  The links to each product look like

http://www.peaceandloveshop.com/zen_shop.esangha-193338254+yin-yang-peace-long-sleeve-dark-t-shirt.php

Here, 193338254 is the product number of the product associated with the link.  Now, the image associated with that product is something like


http://images.cafepress.com/product/193338254v7_150x150_Front_Color-Black.jpg


OK, that doesn't look easy but the trick here is you don't need everything in the image file name.  So if you have a link to the product all you need to do to access an image on the CP servers is this format:

http://images.cafepress.com/product/<[productno]>_150x150_Front.jpg

where <[productno]> is the product number.  This works for every product type.  In fact, for multi-coloured products it will display the colour you defined as the default in CP's product designer.

Given the example above you can make all of these:

http://images.cafepress.com/product/78394184_100x100_Front.jpg
http://images.cafepress.com/product/78394184_150x150_Front.jpg
http://images.cafepress.com/product/78394184_240x240_Front.jpg

Section Links

Section links look pretty much the same as product links.  

http://www.peaceandloveshop.com/zen_shop.esangha.6799111+peace-in-america.php

Here 6799111 is the section id and 'criticalgraphic' is the CP shop id.  Making an image file from this information is a bit more difficult. The images that go with these links look like.

http://logo.cafepress.com/1/1030624.6799111.JPG

Yeah. The section id has been converted from its text form (esangha) to its numeric (1030624).  That's OK. Just get the numeric code from any product image in that store.

The other trick is the "/1/" but as it turns out that's pretty easy too.  It's always the last digit in the section number.  So:

http://logo.cafepress.com/2/1030624.666952.JPG
http://logo.cafepress.com/1/1030624.626131.JPG
http://logo.cafepress.com/9/1030624.1675009.JPG

Not so hard. If you're doing this for images from your own store, you should be pretty much good to go.

There are some potential wrinkles.

Sometimes the images are .GIF not .JPG!!  Doh!  So far that's been rare in my experience.  I think if the shopkeeper uploads a .gif for the image then CP doesn't bother converting it to JPG.  <sigh>  For my purposes I leave .JPG as the default but have coded a mechanism to manually override to .GIF if the image isn't working, which is the case at only one shop I affiliate with and so far only about a third of his images.  

For cpshops featuring affiliate content the other issue is these images are as big as the original shopkeepers display them on their stores.  When they upload 300X200 images that can really muck around with your format.  You can just resize them with the image tag but sometimes that's pretty ugly.  If there aren't too many of them you can download the image and store a resized version on your own servers.  Then you can have your code load the local image instead.

I've created another sample code block that generates image URLs for an affiliate store that handles all the wrinkles. There are more efficent ways to do this, but it works.


Handling Aliases

The last kind of cpshop link looks like

http://www.peaceandloveshop.com/zen_shop

Which is the top-level link to an alias.  Of course there are no CP images associated with these. However, you probably created some for your shop so while you're in there make some links to these too.  It helps if your image files are in the form

http://www.peaceandloveshop.com/resource/zen_shop.jpg


p.
« Last Edit: 12/01/11 at 08:36:01 by Hex Angel - Patrick » Logged

CPSHOP
www.PeaceAndLoveShop.com Namaste
BLOG
www.TheNomadicSpirit.com Inspired by travel
www.GodBeautyPerfectionLove.com Inspired by spirit
www.MyMuseMoviesMusicAndBooks.com Inspired by the arts
evets
Silver Dragon
***

Posts: 29



Go Scots!
   

Re: Extracting CP image URLs from cpshop links
« Reply #1 on: 09/05/09 at 02:52:32 »
Reply with quote Modify message


on 04/04/07 at 18:00:13, Hex_Angel wrote:
Eventually I'll post a tutorial for modifying a search engine to output images as part of its search results, but I haven't decided I'm going with the current one yet.


Hi Hex Angel,

What you've done with the search engine looks great to me! Any hope for that tutorial? BTW, I've PM'd you about it.
Cheers, S.
Logged
Hex Angel - Patrick
Gold Dragon
****

Posts: 500



Our nature lies in movement; complete calm is death.
   

WWW
Re: Extracting CP image URLs from cpshop links
« Reply #2 on: 09/05/09 at 13:48:59 »
Reply with quote Modify message

Oy...that was a looong time ago now.  Hmmmm. . .

If I write it at all, it's not likely to happen any time soon.

For anyone with decent programming skills, it's not all that hard to make the changes required in most of the custom search engine packages I've looked at.

Ciao,

Patrick.
Logged

CPSHOP
www.PeaceAndLoveShop.com Namaste
BLOG
www.TheNomadicSpirit.com Inspired by travel
www.GodBeautyPerfectionLove.com Inspired by spirit
www.MyMuseMoviesMusicAndBooks.com Inspired by the arts
Pages: 1 Reply Notify of replies Send the topic Print 
Jump to:


marty.net message board (http://www.marty.net/cgi/marty/board/messageboard)

Powered by YaBB 1 Gold - Release (Yet Another Bulletin Board)
Copyright 2000-2001, X-Null. All Rights Reserved.