curtacircuitos / octopart-google-app

Octopart Google App
GNU General Public License v2.0
35 stars 14 forks source link

image support #3

Closed boneskull closed 9 years ago

boneskull commented 9 years ago

Hi,

I'd like to view thumbnails with a link to a larger image.

I'm not experienced coding addons, so I'm not sure the best way to do it.

I'm thinking:

  1. Load jQuery when the addon is enabled. I don't know the best way to do this.
  2. When =OCTOPART_IMAGE('foo') is used, ask the API for include[]=imagesets
  3. Return the first ImageSet result with a non-empty value. Use URLs from swatch_image and large_image; insert following HTML fragment: html <a href="{large_image}"><img src="{swatch_image}" title="{mpn_or_sku}"/></a>
  4. I think that's about it.

I'm sure this is pretty trivial, but I don't know about 1., which is why I didn't just do it.

boneskull commented 9 years ago

Perhaps third param to the OCTOPART_IMAGE function which would simply be a swatch, small, medium, large value which would default to swatch.

Alternatively, the URL could simply point to the part instead of the large image.

phsilva commented 9 years ago

I think OCTOPART_IMAGE should return an url and then you can use =IMAGE(OCTOPART_IMAGE(...))

IMAGE is buil-tin on Google Sheets and display the image for you. Not sure about how to handle the link. HYPERLNK functions seems to not accept an IMAGE as the label.

boneskull commented 9 years ago

OK, neat.

phsilva commented 9 years ago

I just published a new version including your function. I just renamed it to OCTOPART_IMAGE instead and added support for a size parameter (optional). Should be updated (version 6) on your spreadsheet soon. Thanks for the contribution.