When you select in a view or in display settings the image_link formatter, doesn't work, because the default option is none instead empty. Fixed:

Before

if (empty($elements['#brightcove_image_link'])) {
  return $image;
}

After

if (($elements['#brightcove_image_link'] == 'none') || (empty($elements['#brightcove_image_link']))) {
  return $image;
}

When you select original image in the style select, doesn'work. Fixed:

Before

if (empty($elements["#{$type}"]->{$elements['#brightcove_image_type']})) {
      $path = brightcove_get_default_image();
      $styled_path = image_style_path($elements['#brightcove_image_style'], 'default-image.png');
      $style = image_style_load($elements['#brightcove_image_style']);
      image_style_create_derivative($style, $path, $styled_path);
      $image = theme('image', array('path' => $styled_path));
    }
    else {
      $remote_file = brightcove_remote_image($elements["#{$type}"]->{$elements['#brightcove_image_type']});
      $image = theme('image_style', array(
        'style_name' => $elements['#brightcove_image_style'],
        'path' => $remote_file,
      ));
    }

After

if (empty($elements["#{$type}"]->{$elements['#brightcove_image_type']})) {
      $path = brightcove_get_default_image();
      $styled_path = image_style_path($elements['#brightcove_image_style'], 'default-image.png');
      $style = image_style_load($elements['#brightcove_image_style']);
      image_style_create_derivative($style, $path, $styled_path);
      $image = theme('image', array('path' => $styled_path));
    }
    else {
      $remote_file = brightcove_remote_image($elements["#{$type}"]->{$elements['#brightcove_image_type']});
      if ($elements['#brightcove_image_style']){
        $image = theme('image_style', array(
          'style_name' => $elements['#brightcove_image_style'],
          'path' => $remote_file,
        ));
      }else{
        $image = theme('image', array('path' => $remote_file));
      }
    }

This is the patch:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jansete’s picture

jansete’s picture

An other problem in the formatter when you choose link to entity or dialog, never store the new value. But now is fixed.

brightcove_field.module
The previous code:

$element['brightcove_image_link'] = array(
      '#title' => t('Link image to'),
      '#type' => 'select',
      '#default_value' => $settings['brightcove_image_link'],
      '#empty_option' => t('Nothing'),
      '#options' => $link_types,
      '#attributes' => array('class' => array('brightcove-image-link')),
    );

    $element['width'] = array(
      '#title' => t('Width'),
      '#type' => 'textfield',
      '#default_value' => $settings['width'],
      '#element_validate' => array('brightcove_field_formatter_width_validate'),
      '#formatter_type' => $display['type'],
      '#states' => array(
        'visible' => array(
          ':input[class="brightcove-image-link"]' => array('value' => 'dialog'),
        ),
      ),
    );

    $element['height'] = array(
      '#title' => t('Height'),
      '#type' => 'textfield',
      '#default_value' => $settings['height'],
      '#element_validate' => array('brightcove_field_formatter_height_validate'),
      '#formatter_type' => $display['type'],
      '#states' => array(
        'visible' => array(
          ':input[name="brightcove-image-link"]' => array('value' => 'dialog'),
        ),
      ),
    );

The fixed code:

$element['brightcove_image_link'] = array(
      '#title' => t('Link image to'),
      '#type' => 'select',
      '#default_value' => $settings['brightcove_image_link'],
      '#empty_option' => t('Nothing'),
      '#options' => $link_types,
      '#attributes' => array('class' => array('brightcove-image-link')),
    );

    $element['width'] = array(
      '#title' => t('Width'),
      '#type' => 'textfield',
      '#default_value' => $settings['width'],
      '#element_validate' => array('brightcove_field_formatter_width_validate'),
      '#formatter_type' => $display['type'],
      '#states' => array(
        'visible' => array(
          ':input[name="options[settings][brightcove_image_link]"]' => array('value' => 'dialog'),
        ),
      ),
    );

    $element['height'] = array(
      '#title' => t('Height'),
      '#type' => 'textfield',
      '#default_value' => $settings['height'],
      '#element_validate' => array('brightcove_field_formatter_height_validate'),
      '#formatter_type' => $display['type'],
      '#states' => array(
        'visible' => array(
          ':input[name="options[settings][brightcove_image_link]"]' => array('value' => 'dialog'),
        ),
      ),
    );

The patch include the new changes and yesterday changes

  • Commit 2108823 on 7.x-5.x by k.dani:
    Issue [#2266341] by jansete, k.dani: Fix image link formatter
    
k.dani’s picture

The first part of the issue is fixed with the first patch. The second part of the issue has been already fixed (Commit 413f621 on 7.x-5.x), so I hide the second patch, because it is not good.

Next time, please create separated issues for different problems to be able to follow them easily. Anyway, thanks for your help.

k.dani’s picture

Status: Active » Closed (fixed)