Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pere Orga’s picture

No, it does not.

But could be implemented. Patches welcome :)

tchopshop’s picture

Yes, I just tested with Picture and saw that it didn't work. I've looked through all the other background related modules and no one else is doing it either but since I'm not a developer, I can't make it happen, unfortunately. Ugh.

tchopshop’s picture

Actually just discovered that the Makeup module works with Breakpoints as a field formatter. I think implementing with Picture might be better, but it's pretty good.

Pere Orga’s picture

Hmm, I've thought about it and now I don't see how we could use picture elements. This module does not insert html elements such as <img/>, but uses inline styles instead to display backgrounds.

Apart from that, note that you can use the srccet attribute in <img> tags, and that may be better than using <picture>. See http://www.smashingmagazine.com/2014/05/14/responsive-images-done-right-...

tchopshop’s picture

The Makeup image module basically uses a field formatter to write css media queries in a stylesheet (or inline) for the background image using different image cache sizes and breakpoints from breakpoint module. I could write my own media queries in my style sheets but I wanted to make use of imagecache to create the various image sizes.

Pere Orga’s picture

I see what you mean now.

tchopshop’s picture

Great... Just in case you're interested in working on it... the picture module would be even easier, since it's a grouping of breakpoints, rather than having to do all the breakpoints and image cache associations all over again inside the field settings.

I just checked out your module contributions... some cool ones I hadn't heard of!

trackleft2’s picture

Assigned: Unassigned » trackleft2
FileSize
11.42 KB

This patch adds picture module support.

I stole a bunch of code from https://www.drupal.org/project/picture_background_formatter So we may be able to combine the two projects.

joegraduate’s picture

  1. +++ b/field_group_background_image.module
    @@ -215,3 +285,106 @@ function field_group_background_image_field_group_pre_render(&$element, $group,
    + * @see picture_background_formatter_field_formatter_view()
    

    This should probably either be changed to * @see field_group_background_image_field_group_pre_render() or removed.

  2. +++ b/field_group_background_image.module
    @@ -215,3 +285,106 @@ function field_group_background_image_field_group_pre_render(&$element, $group,
    + * @see picture_background_formatter_generate_background_css()
    

    This should be changed to * @see field_group_background_image_generate_background_css().

  3. +++ b/field_group_background_image.module
    @@ -215,3 +285,106 @@ function field_group_background_image_field_group_pre_render(&$element, $group,
    +
    

    Coding standards nitpick: extra newlines should be removed.

trackleft2’s picture

Thanks @joegraduate, I'll re-roll with your suggestions. Probably also need a database update in this one for the formatter_type change.

Used to be open and now changes to image and picture

trackleft2’s picture

BTW I also tried the switch case method for the settings form, as shown here: https://www.drupal.org/node/1017962 under hook_field_group_format_settings but the form api #states functionality worked better. Would rather use the switch case method, since it affects what is shown in the field_group settings when you save them on the entity field display page.
Problem is, my settings variables don't ever get set using the switch case method.

trackleft2’s picture

Here are the changes suggested by @joegraduate

trackleft2’s picture

Testing on a fresh install I found some issues. Patch rerolled to handle them.

ShaneOnABike’s picture

Status: Active » Reviewed & tested by the community

Oh man! This is exactly what I've been needing to properly integrate some picture/breakpoint configurations. I have tested it and it works amazingly! Responsive exactly as I needed yahoo!

Can we port this into the actual project!

ShaneOnABike’s picture

Okay I found one gotcha! Presently, this doesn't work with ajax loader on views. If I enable that on say the pager then the next set of images aren't loading properly. Why? Because the add_css call that is being made doesn't add the css background image :/ I am not sure whether we need a special ajax callback function to inject more css (or even if that's possible at all)

trackleft2’s picture

I've been getting this error Notice: A non well formed numeric value encountered in field_group_background_image_generate_background_css() on php7.

trackleft2’s picture

omarlopesino’s picture

Hi.

This patch works greats for picture, thanks!

We add a patch which do the following improvements:
- Solve problem for #10, allowing it to work with old config. This save work when updating the module.
- Fix a warning when showing background image for images, not for pictures:
Notice: Undefined property: stdClass::$field_name en field_group_background_image_field_group_pre_render() (line 210...

Please review, thanks!

omarlopesino’s picture

Status: Reviewed & tested by the community » Needs review
trackleft2’s picture

The patch in #18 works for me thanks! RTBC IMHO

CRZDEV’s picture

Here goes a new patch adding possibility to alter used url, made here as we need this changes (using breakpoints & picture).
This is mainly to allow other modules alter image url (to add invalidating cache params for example).

CRZDEV’s picture

Adding new files renaming drupal alter function according to module name.

Pere Orga’s picture

Apologies for not having reviewed nor tested that, I no longer use this module in Drupal 7 myself. A review by others would help too.

+  if(module_exists('picture')){
+    $format_types[] = 'picture';
+  }

Missing space after if and after ('picture')).

+  $format_types = array('image');
+  if(module_exists('picture')){
+    $format_types[] = 'picture';
+  }
   return array(
     'display' => array(
       'div_background_image' => array(
         'label' => t('Div (with background)'),
-        'format_types' => array('open'),
+        'format_types' => $format_types,
         'instance_settings' => array(
           'classes' => '',
           'show_label' => '',
           'background_image' => '',
           'image_style' => '',
           'background_color' => '',
+          'picture_mapping' => '',
+          'fallback_image_style' => '',
         ),
-        'default_formatter' => 'open',
+        'default_formatter' => 'image',
       ),
     ),
   );

Not sure why 'open' is removed here. Ideally, having the Image module enabled should not be required (even if 99.9% of Drupal sites have it).

drupal_alter('field_group_background_image_generate', $url, $info);

Should field_group_background_image_generate have a better name? AFAIK it should refer to the data being passed.

Pere Orga’s picture

Status: Needs review » Needs work
AstonVictor’s picture

Status: Needs work » Closed (outdated)

I'm closing it because the issue was created a long time ago without any further steps.

if you still need it then raise a new one.
thanks