Zen Cart Logo
Forums / General Questions / Generate images with absolute paths

Generate images with absolute paths

Views: 813

Results 1 to 4 of 4
4 Sep 2012, 4:39 PM
#1
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Generate images with absolute paths

Hi guys,
I'm creating a jQuery Mobile version of my website and have run in to a problem.
The problem lies with JQM rather than Zen Cart but I'm more confident of getting a quick solution from you guys over here than the guys over at JQM!

The problem I have is to do with images with relative paths. JQM isn't very good at handling them it seems, so I'm wondering how difficult it would be to change the zen_image function to generate absolute paths rather than relative?

It would need to work in http and https mode.
Is this something that can be done relatively easily or would it be fraught with problems?

5 Sep 2012, 1:33 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Generate images with absolute paths

damiantaylor:

The problem I have is to do with images with relative paths. JQM isn't very good at handling them it seems, so I'm wondering how difficult it would be to change the zen_image function to generate absolute paths rather than relative?

I can't comment on the difficulty of doing this, but personally I think it is the wrong approach to the problem. Absolute paths are best avoided for many reasons, and if they are required it is best to use them only in those particular circumstances where needed.

In your case, the best solution (IMO) would be to modify JQM rather than ZenCart. This shouldn't be too difficult, it'll just be a matter of prepending the domain name to the relative image paths available to JQM.

Cheers
Rod

5 Sep 2012, 7:07 AM
#3
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: Generate images with absolute paths

Thanks Rod,
My feeling was changing to absolute paths would give me a nightmare later on but I just wanted to see if anyone else agreed :)
JQM already does prefix the path with the domain....that's the problem.....it just doesn't do a very good job of it!
Well, it doesn't if you're re-writing your URLs with one of the mods such as Ceon URI mappping. If you re-write the URL, JQM prefixed the image path with the re-written URL rather than the true URL.

I've been given a really easy solution though so if anyone else here tries to create a JQM site and has this problem, here's the fix.....

Prefix the image path with a slash.

That's it, just make your image source '/path/to/image.jpg' rather than 'path/to/image.jpg' and JQM will leave it alone.
Easy! :)

5 Sep 2012, 12:10 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Generate images with absolute paths

damiantaylor:

I've been given a really easy solution though so if anyone else here tries to create a JQM site and has this problem, here's the fix.....

Prefix the image path with a slash.

That's it, just make your image source '/path/to/image.jpg' rather than 'path/to/image.jpg' and JQM will leave it alone.
Easy! :)

If you (or others) need a little more info as to the technical difference between the with/without slash, here's a link to one of the many tutorials.
http://www.communitymx.com/content/article.cfm?cid=230ad

Cheers
Rod