Previewing of image selected from vocabulary does not work when using clean URL's. (in IE little red cross in the top-left corner of the preview area).
Putting "?q=" in front of the image URL fixes the preview. Inserting the selected image does work though, whether the previewing works or not.

CommentFileSizeAuthor
#1 htmlarea_insert_image_preview.patch871 bytesjcosters

Comments

jcosters’s picture

StatusFileSize
new871 bytes

The reason for the preview not working is that I am running drupal under a subdirectory of my webroot.

Using clean URL's, the URL presented in the textfield next to the preview button is like: image/view/X. When clicking the preview button the browser tries to load http://hostname/image/view/X instead of http://hostname//image/view/X into the preview area.

Not using clean URL's, the ?q=image/view/X URL somehow does resolve to http://hostname//?q=image/view/X.

I provided a patch that fixes this using $base_url, constructing an absolute path that works either way (clean URL's enables or not).

jcosters’s picture

hmm, between the two slashes in the URL's above there should be "subdir".

Anonymous’s picture

This is the wrong approach. If you need an absolute URL rather than relative, you should instead specify TRUE for the 4th parameter to url()

As in:

url('image/view/', NULL, NULL, TRUE)
jcosters’s picture

Sorry for my ignorance.

I got it to work now without absolute URL's by adding a trailing slash ("/") to the base tag's href value inside the insert_image.php file. In the popup window I noticed it missed a trailing slash compared to the base tag of a normal drupal page (bluemarine theme).

Now all URL's are correct and I can preview the images.

jcosters’s picture

do not use the patch above. it is no good.

gordon’s picture

Assigned: Unassigned » gordon

Just let me say for the record, IE is crap!

If you are using a version of htmlarea less that 1.55 then IE will choke. I have fixed it properly and I am not having to use absolute url's which are a real pain.

I have done alot of work on this for a client recently and managed to track down the IE problem. Basically what it was, is that there is a difference between the format of the base url in drupal and htmlarea. drupal has no trailing slash, but htmlarea has a trailing slash. I add this in and it all works fine.

I have re-tested this, and I actually found that the preview will only work with clean urls. I have made a change, which will fix this.

jcosters’s picture

So I wasn't flipping about the trailing slash (see comment #4). Only, I saw a trailing slash in a bluemarine-rendered page and no trailing slash in insert_image.php. Adding one to the base tag's href attribute in insert_image.php fixed it.

I'll double check the previewing not using clean URL's, but I thought it worked yesterday.

gordon’s picture

It wasn't the '/' and the base url on the insert_image.php, it was the htmlarea.baseurl (?) parameter from the setup that was being stuffered up.

The other one is ok, and is in the same format as drupal.

As for the preview not working with clean url's the preview would create an invalid url so it will not bring down the closest resolution image. I had to take this out. I will add it back soon.

jcosters’s picture

Well, it seems I keep on telling half-thruths and making crappy patches which Gordon has to correct because of my inexperience with both PHP and Drupal.
Sorry Gordon! And thanks of course for correcting my statements and patches.
Just trying to help out and learn things.

Anonymous’s picture

Anonymous’s picture

sorry to open this up again, but the preceding messages have me thoroughly confused.

I am having the same preview issue problem with drupal installed in a subdir using clean URLs.

It has nothing to do with IE, cause it happens in firefox too.

So what exactly is the solution?

gordon’s picture

I have tested it with both firefox and IE, and it works with the latest version of htmlarea. I am not too sure what is wrong with your setup.

Anonymous’s picture