I am surprised not to find a feature that I thought would be a given when I saw that you can specify how many images can be uploaded. Yet then, when I uploaded all the background images my client wanted to be used for the background (one randomly every time a page loads/reloads), I found that you can just pick one to be the background?

The whole point of "Dynamic" for me was for it to be changeable, not just via UI, but also to be randomly selected and changed by code. Is there any way that this can be done, that Dynamic_Background PICKS an image from those uploaded and shows it as the background, without me having to make a module with a hook, or my own jQuery code? If not, seriously think this module needs this feature. Thanks!

Comments

mahnster’s picture

It was even expected, by just what I would think of a module with this name, that it may even, with JavaScript, change the background without the user reloading, and even fade out fade in with a new background, such as black and white photos of a city's skyline (which is what my project requires, but not necessarily reloading the images without a reload, but still would be cool, to have a time between changes to set, etc.)

cableman0408’s picture

Category: support » feature

This is currently not possible, but I like your idea's an this might be something that I'll look into and try to get into the module.

mthiner’s picture

subscribe: even if someone could write a script for this module, that would be helpful...

RubenV’s picture

I hacked this quick and dirty into the dynamic_background.module file.

In that file, replace the 'dynamic_background_dynamic_background_css' function with the following code:

/**
 * Implements hook_dynamic_background_css for the main module.
 */
function dynamic_background_dynamic_background_css($vars) {
  $image = variable_get('dynamic_background_active', FALSE);
  $image_style = variable_get('dynamic_background_image_style', FALSE);
  if ($image) {
    return array(
      'image' => $image,
      'configuration' => variable_get('dynamic_background_css', array()),
      'image_style' => $image_style ? $image_style['style'] : FALSE,
    );
  }
  // if none is selected pick one rancom from the uploaded images
  else{
    $images = variable_get('dynamic_background_images', FALSE);
    $selected = array();

    // skip the empty ones
    foreach($images as $image){
      if(isSet($image['picture']) && $image['picture'])
        $selected[] = $image['picture'];
    }

    if(empty($selected))
      return false;

    $image = $selected[array_rand($selected)];

    return array(
      'image' => $image,
      'configuration' => variable_get('dynamic_background_css', array()),
      'image_style' => $image_style ? $image_style['style'] : FALSE,
    );

  }
}

This is ok for my situation, but maybe someone can add some setting to switch this functionality on and off...

cableman0408’s picture

The patch above only applies to the 1.x branch :-)

cableman0408’s picture

Status: Active » Needs review

I have updated the code to add support for random image selection as a configuration option in the 7.x-2.x development branch.

It have also been built into the extensions.

DD 85’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Status: Needs review » Active

I also interested in the function of the random background image.

TarekElTabey’s picture

Hey, thanks a lot for Great, Powerful yet Simple module :)
I would like to ask something about your addition "It have also been built into the extensions."
When I enable "Random Image" for the general Settings, I do this because I want all the site pages to display rotating and random images.

But then I use Context to choose an image for each Taxonomy, but the random image also displays in the taxonomy pages, although I disabled "Random Image" feature in Dynamic Backgrounds Context Settings..

Help, Please?
Thanks, Tarek

deanflory’s picture

Tarek, just a thought, but maybe changing your Dynamic Background Weights would create a logic that fits your needs? I have no idea if the random functionality is contained in the weighted option "Dynamic background" on the following admin page or not as there is no "Dynamic background random" item:

/admin/config/user-interface/backgrounds/weight

DHL’s picture

This module works like a charm. Since I want each node has its own background. But that will occupy a lot of disk space if those background pictures are reside in local disk. Is there a way to use the picture that is reside in online photo hosting ?

deanflory’s picture

DHL, start a new issue please.

TarekElTabey’s picture

deanflory,

Thanks for your quick reply,
and sorry for my late one :S

I checked the weight feature, it's organized in a manner that serve my needs,

but let me ask the question in a different form..

I realised that the module is set -automatically- to slideshow the images uploaded on each refresh, Am I Right?

if so, can't I PAUSE or STOP this slideshow feature when displaying Taxonomy pages, and let the Context display the background I've chosen for each Taxonomy page???

Sorry for the complication requested :)

Thanks, Tarek

deanflory’s picture

Without looking at what settings this module has (doing updates at the moment), can't you just rearrange the weighting so that taxonomy or node backgrounds outrank whereever you've been able to set up the random slideshow (or random upon refresh)? That way if you have a general background site-wide, it would be weighted so it is below the node background if one is set, thus showing a node's background if one is selected or uploaded for that one node or taxonomy term.

I haven't looked lately to see if it does have a slideshow feature (nice) but I imagine if it did it wouldn't have a pause or stop button for a page background. You just need to sort your weights.

These are the options on the project page, not seeing one specifically that covers taxonomy, but maybe the context can cover that either directly via taxonomy vocabulary or via path alias recognition:

  • User - This extension allows authorized users to select a background image to use when they are logged in. If a used have selected a image it will override all other background image selection. The image is selected on the "My background" tab on the user profile page (e.g. /user/1/backgrounds).
  • Blog - This extension allows users to select a background image for their blog pages and entries. The image is selected on the user profile on the "My blog background" tab on at the user profile page (e.g./user/1/blog/background).
  • Panels - The panels extension allow you to select a background image for a given panel variant. The image is selected under "General settings" in the variant of the panel that should use a given image.
  • Node - This extension allow each node to have its own background image. You can select which content types should have this ability in the administration interface. The image for a given node is selected in the individual node edit form, when creating or updating a node.
  • Views (beta) - This extension enables administrators to select dynamic background images in views, so each view can have its own image. This is achieved by exposing a new display in views called "Page (dynamic background)", which under page settings have an option to select the image.
  • Context - The context extension allows administrators to select uploaded images base on different contexts using the context module. Such contexts as path, role, node type or taxonomy and may more conditions.

I'm unsure if you can change weights on contexts so that context 1 has a greater weight over context 2. You'd need to look into that and see if that is an option.

drupal a11y’s picture

On the topic of "rotation": is there a way to integrate / support the "vegas"-module: https://drupal.org/project/vegas ?

deanflory’s picture

Scrollshow is in development and isn't necessarily a solution for a background image slideshow without scrolling, but with scrolling it can change the background "video" (series of images). When this module gets stable it should be pretty slick with the parallax layers and other goodies. Holding out for the Views integration though.

https://drupal.org/project/scrollshow

tanius’s picture

Issue summary: View changes
Status: Active » Needs review

This should be in "Needs review" status due to the code from #6, which is in 7.x-2.0-rc4 already.

My review: Works as expected, no flaws found in some months of use. Anyone else?

GiorgosK’s picture

random images is a great idea
but how would it affect caching ? anybody knows ?