Just curious how folks are dealing with the background issue in the Imagepicker iframe. On my site, the iframe is picking up the main page background image and color. Setting the background attributes in imagepicker.tpl.php has no effect. Same with setting the background attributes in the imagepicker.css file. No luck. The body and tbody tags in the css file are not being applied. I even changed them to classes using imgp_body and imgp_tbody. I have also tried using a 1x1 pixel white .gif for the background of the iframe page body tag. Nothing works.
Apparently, there are major issues with CSS and iframe compatibility (from what I have found with a quick Google search).
Anyone have a fix?
Comments
Comment #1
hutch commentedI would agree that using iframe is problematic, but I have found that imagepicker does pick up the css with the more 'conventional' themes, such as Bluemarine or Foliage. It loads style.css and makes use of the primary and secondary classes which some themes have not defined. With the more complex themes such as Tapestry it goes woefully wrong, these are dynamically loaded from variables generally set in template.php. With themes using the colorwheel such as Garland or pixture_reloaded imagepicker comes out with the default colors but does pick up the rest of the css.
The only way I can think of to get rid of the iframe would be a rewrite to make it use Jquery with ajax, not so simple.
So no easy solution but there are some workarounds
Here is some experimental code, not tested
replace the existing theme_imagepicker() function with the above and copy 'imagepicker.tpl.php' to the default theme directory and edit that to suit your needs. If anyone tries this please report back ;-)
This should work for D5 and D6
Comment #2
bradnana commentedTried it. No difference.
I really can't tell by the code you've added what you are trying to do. The only difference is in the conditional checking for $defaulttemplate.
FWIW, apparently none of the css is being applied inside the iframe. Even the 'Upload' and 'Browse' tabs are not showing up as tabs. Rather, they appear as a vertical list.
Just throwing out ideas here, but what about opening it in a popup? IMCE works this way. Also, ImagePicker looks and acts very similar to Google Blogger's image uploader and it opens in a popup. It has a few other features that might be worth mimicing, too, like offering multiple upload fields and the option to link to an image on the web. (And uploading video... hint, hint... but I digress.)
On that note, I have seen mention of the need to disable the image button in TinyMCE, but it still works for me. I left the image button on and can (attempt to) edit a picture once it's uploaded and placed using ImagePicker. I'm guessing that TinyMCE images are styled with Tiny specific css or somesuch and that's why the alignment properties set by IP do not show in the Tiny image editor fields. I also notice that I cannot actually use IP to edit an image I have already placed in the story. Instead, I have to delete and replace it to make changes (or edit the code by hand).
Sorry about polluting this thread-- just had several things pop into my head at the moment. ;)
Comment #3
hutch commentedThe purpose of the code is to look into the default theme's directory and if a file named 'imagepicker.tpl.php' is found, use that one instead of modules/imagepicker/imagepicker.tpl.php. This means you can tweak imagepicker.tpl.php to suit your theme without losing your tweaks on the next imagepicker update, I've just tried it and it works.
Drupal uses
<ul>to build tabs. Garland for instance shows Upload and Browse as a vertical list because it cannot find the images it uses. If you copy imagepicker.tpl.php into the Garland directory they will be rendered properly, I've just tried it and it works. I'll be adding the changes to theme_imagepicker() to the dev versions shortly, it's clearly an improvement.Ugh. The reason for avoiding popups is that it will not solve the css problems and they get lost behind the main screen or get blocked by the browser. Inexperienced users get confused by these things. I host a number of Drupal sites and have run across these issues many times.
Already there, select Show: title and Link: File, page or lightbox
As for video, Lightbox2 supports videos I believe. Using http upload for large files is fraught with difficulties, requires massive timeouts and huge upload max settings. Some of these settings are global in php and will cause all sorts of problems on a hosting server.
I'm trying to keep imagepicker as simple as possible and avoid the 'creeping featuritis' that only confuses some users, the vast majority of my customers for starters.
More advanced users can use the more complex modules, the main thing is to provide choice, Horses for Courses.
Comment #4
bradnana commentedHey thanks for the reply. If by 'works' you mean that the module is still operable with the new code in place, then yes it 'works'. However, it doesn't seem to make any difference with reference to the CSS getting muddled. In all fairness though, I didn't do anything to 'tweak' the template. I was under the impression that Drupal would locate a template file for any module by looking in the default theme directory first anyway. But considering the problems with the iframe, it would be a pain to have to 'refix' it everytime ImagePicker was upgraded. So, using the theme override should be handy.
As far as the tabs, if I can ever figure out a way to get the browser to apply the right CSS to the iframe, I think the tabs will display correctly. But this has escaped me so far. Like you said, the iframe is picking up the styles.css file and applying the body selector.
I think you misunderstood my comment about "the option to link to an image on the web". I'm not refering to linking the picture. I'm refering to being able to paste the URL from an image that is already available on the web and have ImagePicker pull it in. Unless I'm missing something (which is highly likely!), I don't think the Show: or Link: options have anything to do with that.
I understand what you mean about avoiding 'featuritis' and totally agree. For other media, I just use the Video and Audio modules and may take a look at Lightbox. Eventually, though, it seems I have to install gobs of modules just to get a reasonable level of functionality for my end users, and they all have different interfaces and workflows. I sometimes think the 'Drupalosophy' averseness to 'featuritis' often leads to 'modulitis', and that entails its own myriad headaches. I just like the looks of ImagePicker and the more normalized UI and workflow it presents as opposed to other more Drupal-like media modules. It's certainly no secret that Drupal's UI and workflow are idiosyncratic.
--Brad
Comment #5
hutch commentedTry rebuilding the menu by going in to admin > menu and editing a menu item, it might be caching
"the option to link to an image on the web"
OK now I understand ;-)
All imagepicker is doing is building up a piece of html and inserting it into the body using javascript, once it is pasted that's the end of imagepicker's involvement.
I just tried pasting an img src straight in and that works but I had to switch off TinyMce
I agree that Drupal can idiosyncratic but at least it's mostly doable and it has a published API which is not complete but it certainly helps.
Hope you can get the tabs up
Comment #6
sjz commentedI've read through this thread and realize that it's not (exactly) as you are describing. The issue is the order in which styles are applied. Unfortunately, the order in which styles are applied are a "Drupal" thing which presents a particular collision with various themes. So this seems to work reasonably well as a work-around:
The easy way:
(that's everything after the header comment up to the definition of tbody {)
with
Of course - you'll need to supply your favorite background color.
Comment #7
hutch commentedYou are quite right, the body and tbody stuff should not be there, I will remove them in the dev versions.
Comment #8
bradnana commentedI just upgraded to the latest version. The body and tbody are no longer in the template but it soes not seem to have made any difference. The iframe still picks up the main site's background. I fixed it by adding two additional id declarations in the imagepicker CSS file and applying them to to the body and table elements in imagepicker.tpl.php as follows:
I also noticed using Firebug that there is no
<ul>element being generated for the "Upload" and "Browse" tabs in the iframe. The following code appears in the template file:<?php echo $tabs ?>Not sure if this call to Drupal is supposed to get a fully formed 'ul' element with 'li' elements nested or whether it only returns the 'li' elements alone. However, I edited the template file like so:<ul class="tabs primary"><?php echo $tabs ?></ul>which is the setup other tabs are using on the same page and the imagepicker tabs now show up normally.Comment #9
hutch commentedThis is a theme dependent problem, I am seeing the following generated by $tabs
You can copy imagepicker.tpl.php to your theme's directory and it will be used instead of the default if you are using the most recent version of imagepicker.
Comment #10
Grayside commentedThe template override does not seem to work in my themes directory- either in all/, or my specific site directory.
Comment #11
hutch commentedIt should be in the default themes directory, that's what imagepicker looks up.
In D6 you will likely need to flush the themes registry, the devel module will do this or just save the theme might do it.
Comment #12
Grayside commentedsites/default/themes? Good to know. It's a little different from usual theme customization practices- inasmuch as I understand what those are.
Comment #13
hutch commentedno no, the default theme currently in use on your site.
You should put contributed modules in sites/all/modules and contributed themes in sites/all/themes
It's all in the drupal docs
Comment #14
gluetown commentedThis did the trick for me.
Comment #15
Grayside commentedThe Thickbox module might be a good candidate for integration to streamline the IFrame.
Comment #16
hutch commentedI will have a look, thanks for the heads up
Comment #17
hutch commentedComment #19
dilovan commentedthat worked with me .. but will there be any problem with updating the module ?
sjz suggestion
1. Remove all of the bad css definitions in imagepicker.css
(that's everything after the header comment up to the definition of tbody {)
2. Edit imagepicker.tpl.php and replace this statement:
with
Of course - you'll need to supply your favorite background color.
Comment #20
hutch commentedI've lost the thread here, what works for you?
BTW, if it's theming you are concerned with, there is much better support in the most recent version
Comment #21
sjz commentedThere are now two template files which need to be modified in the same fashion
the same changes apply
Replace
<body>with
<body style="background: white;">(or whatever your favorite color should be)
and Yes - You will need to remember to do this when you do updates.
-steve
Comment #22
gaellafond commentedThe issue title seems to has been accidentally changed. I replaced it.
@steve (aka sjz) No, you don't have to modify the file in the module, just copy the template file (imagepicker-page.tpl.php with latest version) to your Theme and modify it there! Hutch modify the module to handle that override feature. You can than update the module over and over, the file in your theme will always remains the same.
That's will work as long as the original template do not change too much over the time, with further updates (it's really simple so it should not be an issue). In that case, you may have to copy it again from the module to your Theme and modify it again in your Theme. The module will use the template from your Theme instead of the original one, if it exist.
@Hutch May I suggest you to add an ID to the body, so we can simply modify the CSS from the theme without having to copy and modify the template. The only modification I had to do to the template was:
And I add those lines to my Theme CSS file:
Btw, thanks for this wonderful module. I just install it and so far, it's exactly what my team was looking for!
I was expecting it to works like the IMCE module, with the popup, just because our users are used to that. But as long as I can remove the image button from the CKEditor, I guess that's will be alright.
Comment #23
hutch commentedI have added
<body id="imagepicker">to CVS so that will appear in the dev version soonComment #24
TWD commentedAll I needed to do was add some inline styling to the tag of the
imagepicker.tpl.php file within the Imagepicker module directory.
<body id="imagepicker" style="background-color:#FFF; background-image:none; line-height:70%;">Comment #25
hutch commentedBetter to copy imagepicker.tpl.php to your theme and do it there, then it won't get over-written at the next update.
Or you can add something like
to your theme's stylesheet.
Comment #26
TWD commentedGood point. Thanks for the heads up.
Comment #27
drummondf commentedSolution number 6 is perfect - thanks!