Jump to content

resizing images used in json / service pages module


formulate
 Share

Recommended Posts

Looking for some advice.

On site A, I have Ryan's Service Pages module installed and am serving data as JSON. On site B, I'm retrieving the data by passing a page ID. This works great for all the data, but for images it is pulling the full image that's stored in the field for a given page. On site A I store full size images as I use them in a variety of ways and use the API to resize them. However, when using the service pages and pulling the data to site B, I don't have opportunity to resize first and thus it's pulling 6mb, 8mb files over every time site B displays the data. I of course resize the images once they get to site B, but it still has to pull that initial full file over. I need the resize to happen on site A first.

So a few thoughts...

1) I could build a caching system on site B that uses cron to execute a script to pull the images, resize them and store them. I'd rather not do this if I can help it and would prefer to rely on a solution that is self-contained on site A.

2) I could use the API on site A to create a compressed version of the file that is publicly accessible via http. I would write up a script that would go through the thousands of pages I have and create these http accessible versions and then create a cron to fire off a script to create these images on a regular basis to account for newly added pages. Not an ideal solution.

3) I could hack the service pages module and somehow resize images before serving the JSON filename.

4) Is the service pages module hookable? That would be preferable to #4 above.

 

Any other thoughts? Some angle or idea I'm not seeing? Thanks for your time looking at this.

Link to comment
Share on other sites

What about a proxy script on site B that gets invoked via htaccess for all images coming from site A. This script determines which variation is desired and redirect to it on site B. 

If the desired variations are yet not pre created, the script from site B must talk to a script on site A that is possible to create a variation before finally redirecting to it. 

Link to comment
Share on other sites

Very interesting. While I don't think I need the .htaccess part, the second half of your response is probably doable in some fashion. Something like this:

Site B tries to pull "optimized" image from publicly accessible url. If it can't get it, it triggers script on Site A to create optimized image and then tries pulling it again. I'll probably have to use curl in order to properly get the 404 call back.

I'll report back once I've rigged something up and tried it. Thanks Horst.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...