Crop conditions are not used when there is multiple image in a entity with the same manualcrop style applied.

The same image crop style applied only once on a single image field works correctly, but once there is more than one image with a manualcrop style, he is just ignoring the minimal and ratio conditions.

the width, heigth (...) in Drupal.settings.manualCrop.styles.some_style.data are stored as array of n element where n is the number of crop styles used (i'm not sure to give relevant information here).

Comments

theio’s picture

Priority: Major » Normal
theio’s picture

I solved this issue by making a behavior turning the crop styles needed turn back to their needed state.

It works with panels, and should work whatever image fields & differents crop styles you use by finding the styles is needed and make them usable.

there is the code :

behavior :

    Drupal.behaviors.myBehaviors = {
      attach: function (context, settings) {
        manualCropFix(Drupal.settings.manualCrop);
    };

main function :


var styles = [];

function manualCropFix (mcs) {
  if (mcs && mcs.fields)
  {
    //make the list of styles to epure
    $.each(mcs.fields, getImageStyle);
    $.each(styles, function(index, val) {
       epurateCrop(mcs.styles[val]);
    });
  }
}

the others functions :

function addStyleCrop (style)
{
  if (styles.indexOf(style) < 0)
    styles.push(style);
}

function getImageStyle (idx, elem) {
  var ret;
  $.each(elem.required, function(index, val) {
    if (val != 0)
      ret = val;
  });
  addStyleCrop(ret);
}

function epurateCrop (style) {
  if ($.isArray(style.effect))
    style.effect = style.effect[0];
  if ($.isArray(style.data.height))
    style.data.height = style.data.height[0];
  if ($.isArray(style.data.width))
    style.data.width = style.data.width[0];
  if ($.isArray(style.data.style_name))
    style.data.style_name = style.data.style_name[0];
  if ($.isArray(style.data.keepproportions))
    style.data.keepproportions = style.data.keepproportions[0];
}