I have a Product content type with an image field, but I'm using the Media browser widget from Media, which prevents me from being able to configure "product image field" on the content type edit form.

It seems like this field should show all image type fields, not just those with the image widget.

However, at the very least we should allow image fields with the Media browser widget to be chosen on the content type edit form. Patch forthcoming.

Comments

joelstein created an issue. See original summary.

joelstein’s picture

Status: Active » Needs review
StatusFileSize
new605 bytes
stefan.r’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new746 bytes

Patch looks great but it would allow for media fields that also allow files/videos so let's make this stricter and add a check for allowed types to be images only...

longwave’s picture

What else is available in that $instance array - can we check the field type instead of the widget type?

stefan.r’s picture

we can't...


array (
  'label' => 'Image',
  'widget' => 
  array (
    'weight' => '14',
    'type' => 'media_generic',
    'module' => 'media',
    'active' => 1,
    'settings' => 
    array (
      'progress_indicator' => 'throbber',
      'preview_image_style' => 'thumbnail',
      'allowed_types' => 
      array (
        'image' => 'image',
      ),
      'browser_plugins' => 
      array (
      ),
      'allowed_schemes' => 
      array (
        'public' => 'public',
      ),
    ),
  ),
  'settings' => 
  array (
    'file_directory' => '',
    'file_extensions' => 'png gif jpg jpeg',
    'max_filesize' => '',
    'max_resolution' => '',
    'min_resolution' => '',
    'alt_field' => 0,
    'title_field' => 0,
    'default_image' => 0,
    'user_register_form' => false,
    'entity_translation_sync' => false,
  ),
  'display' => 
  array (
    'default' => 
    array (
      'label' => 'above',
      'type' => 'hidden',
      'weight' => '5',
      'settings' => 
      array (
      ),
    ),
    'teaser' => 
    array (
      'label' => 'above',
      'type' => 'hidden',
      'weight' => '24',
      'settings' => 
      array (
      ),
    ),
  ),
  'required' => 0,
  'description' => '',
  'id' => '148',
  'field_id' => '87',
  'field_name' => 'field_test',
  'entity_type' => 'node',
  'bundle' => 'some_bundle',
  'deleted' => '0',
)

  • longwave committed 7bdb369 on authored by stefan.r
    Issue #2551289 by joelstein, stefan.r: Add support for image fields...
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed #3.

joelstein’s picture

Thanks!

Status: Fixed » Closed (fixed)

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

retiredpro’s picture

StatusFileSize
new1.05 KB

Hi guys,

Patch #3 works if you simply change the image widget from Image to Media Browser. It has the following structure which the patch checks for... $instance['widget']['settings']['allowed_types'] == array('image' => 'image')

'allowed_types' => 
  array (
    'image' => 'image',
  ),

If you edit and resave the field though, the allowed_types array changes to the following and no longer passes the condition.

'allowed_types' => 
  array (
    'image' => 'image',
    'video' => 0,
    'audio' => 0,
    'document' => 0,
  ),

I've updated the patch to check for either array structure.

tr’s picture

??? What's the point here?
Patch in #3 was committed to Ubercart more than three years ago ...