How to align image at a center of a block? I tried https://drupal.org/comment/5129366#comment-5129366 but it isn't work. Here is generated code of my field:

it has "float:left" block and some "position:absolute" blocks, so how can i centered it? My images has different width, so i can't use "margin: 0 auto". It there a way to do it? Thanks.

CommentFileSizeAuthor
absolute.png21.66 KBNikita Petrov
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andyg5000’s picture

Title: How to center the image? » Allow site builders to override settings in field formatters
Category: Support request » Feature request

Changing to a feature request because it'd be nice to specify your settings overrides in the field formatter which I don't believe is currently possible.

In the meantime, you can override the js and include your own settings for the plugin by doing the following:

* Create an imagezoom.js in your theme directory
* Add scripts[] = imagezoom.js
* Write your own selectors and init the plugin on them with your overrides.
* Note, you'll need to make sure you have a selector and elevateZoom() init for everywhere you want the image zoom to happen.

(function($) {

  /**
   * Initialize image zoom functionality.
   */
  Drupal.behaviors.imagezoom = {
    attach: function(context, settings) {
      // Create a selector only for the view we wish to alter.
      var view = $('.view-store-catalog-lists', context);

      // The 1st and second columns have image zoom to the right.
      $('.col-1 .imagezoom-image, .col-2 .imagezoom-image', view).elevateZoom({
        zoomType: 'window',
        borderSize: '1',
        zoomWindowHeight: '175',
        zoomWindowOffety: -25
      });

      // The third column needs to have the zoom to the left.
      $('.col-3 .imagezoom-image', view).elevateZoom({
        zoomType: 'window',
        borderSize: '1',
        zoomWindowHeight: '175',
        zoomWindowOffety: -25,
        zoomWindowOffetx: -650,
      });
    }
  }

})(jQuery);
davisben’s picture

Version: 7.x-1.2 » 7.x-2.x-dev
Status: Active » Fixed

In the 7.x-2.x version, there is hook_imagezoom_settings_alter() that allows you to change the settings that are sent to the elevatezoom plugin. I added imagezoom.api.php to document that hook.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.