I've installed the background image kit feature, but every time I go to the theme config page and click on the background image drop down box, there are no images listed (see attachment image).
There are definitely images in the correct directory. The images bundled with the theme are there, and can be viewed at the URL where they reside.
Any thoughts?

Nick

My drupal install info - OS/DB etc also attached FYI.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zandros’s picture

This is what I have done to fix this:

I opened the background-imagekit-theme-settings.inc in the folder: sooper-background-imagekit
and I edited the following lines:

line 13: foreach (file_scan_directory($theme_path .'images/backgrounds', '.jpg') as $file) {
(the reg exp that includes all types of images is not correct, so as you can see I have just changed it to .jpg)

line 14: $bg_images[$file->name] = $file->name;
(filename now stands for path and not name)

and line 15: $bg_image_suffix .= '<p>'. $file->name .'</p> <div class="demo-background" style="background:url(/'. $file->filename .');"></div>';

uri has been replaced with filename and filename with name.

nicktr’s picture

FileSize
36.04 KB

Thanks for your fix.
I've made the changes and the configurator now displays the available backgrounds in the dropdown box, but doesn't actually show the images below the dropdown box.
See attachment for screen shot.
I've figured out why:
Using element inspector in Google Chrome I can see the URL for the images is incomplete.
My site is in a subdirectoy of root, and this subdirectory is not being used to reference the images. I guess this has something to do with lines 14 and 15?
I.e.
It should be:

site.com/subdir/sites/all/themes/tundra/sooper_tundra/images/backgrounds/img.jpg

but instead it's just

site.com/sites/all/themes/tundra/sooper_tundra/images/backgrounds/img.jpg

If I hard code the name of the subdirectory into the background-imagekit-theme-settings.inc at line 15 (in the background:url)

$bg_image_suffix .= '<p>'. $file->name .'</p> <div class="demo-background" style="background:url(/subdir/'. $file->filename .');"></div>';

It shows me the images correctly in the configurator.
However, it does not show the image in the background. Perhaps this is also a path issue.

Any help much appreciated!!

zandros’s picture

As I see on my working environment, after the fix that I have implemented, the image that is set to the background is something like that:

background-image: url(/themes/tundra/sooper_tundra/images/backgrounds/white-grunge_concrete_plaster);
It gets the file's name (from the select list) and looks it in the path /themes/tundra/sooper_tundra/images/backgrounds/.

Since you know how to use the element inspector, I would suggest to you to inspect the element body after you have selected a background image in the "tundra theme configuration" and see if it actually sets a relevant path or something else.

nicktr’s picture

I've done as you said and can see that no background image is set at all for the body, after saving in the configurator.
I guess this is linked to the issue 'settings do not save' http://drupal.org/node/966108

-osiris-’s picture

Status: Active » Patch (to be ported)
FileSize
2.55 KB

Hi.
Let me suggest this patch, solving the Regex issues, thus scanning for png, gif and jpg as well as fixing the subdir issue, where drupal installations below webroot level would point the background image to the wrong path.

Also merged in is suggestion of comment #1.

-osiris-’s picture

FileSize
49.84 KB

The changes made required some more rewrite of your code, nothing drastical, but you often had the path coded in a way, that content would not get included if drupal resided in subdirectories. Fixed that, so with this patch the imagekit should be fully functionable.

JurriaanRoelofs’s picture

Thanks for your work osiris. My working copy of the theme is not the same as the CVS version so I'm going to have to apply the patch manually, what is it exactly that you have done? I think the main problem is that $base_url needs to be used so that urls correctly point to Drupal installations in subdirectories right?

But whats going on with the liveprevies javascript, it seems to change nothing in the background image url?

I'm still not sure about what problems play here exactly but the part of my code that looks dangerous is using ../../../$theme_path or even just $theme_path, instead I shall replace these instances with with $abs_theme_path as this will always point to the drupal installation path.

JurriaanRoelofs’s picture

also, I believe your patch refers to code from the Drupal 7 version is that right? because this issue is listed as Drupal 6

JurriaanRoelofs’s picture

Please update your Tundra installations to version Beta 2. I got a bunch of cvs errors before I could tag the beta so also please let me know if you spot a problem with this, I really dont get along well with CVS myself..

I put this important message on the project page, please make sure you update the features along with the Tundra theme itself:

"Make sure you download the zip files for the right version of the Tundra theme, If you update your Tundra theme to a newer version, you must also download the new zips from here. If you hover the zip links you can see they point to a specific version, this version should always match the version of the Tundra theme."

-osiris-’s picture

I hope you had a nice holiday, peach.

Firstly, my patch referres to drupal 6.x, precicely 6.20, if that is of value.

Second, where do I get the Beta 2, drupal.org still only lists Beta 1?

Third: Problems with the includes are caused by drupal being installed beneath webroot. To solve this, exact paths my be more useful.
That means, they have to be adressed in
features/sooper-background-imagekit/background-imagekit-theme-settings-css.inc.
You should in fact point the bg-image to

/*
 * from features/sooper-background-imagekit/background-imagekit-theme-settings-css.inc
 */
$CSS .= "html body {background-image: url('".$base_url. $abs_theme_path ."images/backgrounds/". theme_get_setting('background_image') ."');}";

Btw, I just noticed what a mess my SVN made, but I do not know how tu really just handle the diff in versions.

Fourth: The other thing I noticed was, that when using any of your plugins, theme_get_setting() causes some troubles. I think this can be fixed by using $settings['setting_name'] instead as often as possible.

Fifth: The regex scanning for the background images colud look like this:

/*
 * from features/sooper-background-imagekit/background-imagekit-theme-settings.inc
 */

$bg_images['none'] = 'none';
$bg_image_suffix = '<p><strong>'. t('Available background images:') .'</strong></p>';
foreach (file_scan_directory($theme_path .'images/backgrounds', "(.*?)\.(jpg|png|gif)") as $file) {
  $bg_images[$file->basename] = $file->name;
  $bg_image_suffix .= '<p>'. $file->name .'</p> <div class="demo-background" style="background:url('.$base_url.base_path().'/'. $file->filename .');"></div>';
+}

Excuse any minor mistakes, I'm just growing used to collaborating on code projects. I'm grateful for any further advice.

greetings,
osiris

JurriaanRoelofs’s picture

thanks, I did have a great time.

I actually forgot to create a release on the project page itself, I've just done that.

regarding the paths, the $abs_theme_patch should point to the drupal installation even if its in a subdirectory, at least thats what I intended it to be used for. The difference of adding the base url shouldn't be relevant, the difference in paths would be

http://google.com/subdirectory/folder/file.png
and without base url:
/subdirectory/folder/file.png

I any case both these urls point to the right file absolutely, at least on my computers, if there is someone who can clarify this that would be great.

JurriaanRoelofs’s picture

Status: Patch (to be ported) » Closed (won't fix)