PDA

View Full Version : Why the blank image?



sfwalter
7 Dec 2007, 5:51 AM
Someone asked me the other day why the need to specify the location of the blank image such as:



Ext.BLANK_IMAGE_URL=''


And I couldn't give them a decent answer. Whats the purpose of specifying the location? Is it because the location of the javascript file and the image directories may not be relative to each like the css and image directories are?

scott.

santosh.rajan
7 Dec 2007, 6:28 AM
Ok let me try. Lets say you copied ext into folder blah inside your document root and renamed it myext.
Ext needs to insert into an image src.
image.src = "blah/myext/resources/images/default/s.gif".
How would Ext be able to figure that path out?

zduniak
7 Dec 2007, 6:54 AM
Ok let me try. Lets say you copied ext into folder blah inside your document root and renamed it myext.
Ext needs to insert into an image src.
image.src = "blah/myext/resources/images/default/s.gif".
How would Ext be able to figure that path out?

The same way as is able to reach other resource files, eg.: "resources/images/default/button/btn-arrow.gif" ?...

I am also interested in the answer to the original question.

Cheers,
Marcin

tryanDLS
7 Dec 2007, 7:01 AM
This has been discussed endlessly both here and in the FAQ - please search before posting.

santosh.rajan
7 Dec 2007, 8:16 AM
zduniak:

That will not work in this case. Because the context is different. You can only specify relative path relative to your original html page. You can specify in your program
<script src="ext2/ext-all.js"> because you know where it is. But as far as the Ext programmer is concerned ext2 directory can be anywhere relative to the directory of your html file.

santosh.rajan
7 Dec 2007, 8:44 AM
Let me add. I picked up this line from inside ext-all.css

url(../images/default/box/tb-blue.gif)
The resource is picked up relative to the location of ext-all.css. Thats fine.
But to insert the same image in your html page you need to know where your html page is in relation to "resources/images".

brian.moeskau
7 Dec 2007, 11:52 AM
Santosh is correct. Think about this page structure:


WebRoot
--Ext
+-- resources / etc.
--MyApp
+-- index.php
+-- Admin
+-- login.php

If both index.php and login.php used an Ext component that required a background image, with relative paths, index.php would require ../Ext/.. while login.php would require ../../Ext/..

Obviously, there's no way for us to guess that -- the only answer is to use absolute paths. From the Ext perspective, the only absolute path guaranteed to work is one pointing at a globally static resource, like our site. The two choices are CSS images that work "out of the box," but yes, do point to a file on our site (not a security or privacy issue, as discussed here (http://extjs.com/forum/showthread.php?p=38079#post38079)), or CSS images that are broken by default, and require you to set up an absolute web path somewhere on your side, even if you are just evaluating Ext, browsing the examples, etc. We chose the former route.