function panopoly_images_form_alter in Panopoly 7
Implementation of hook_jorm_alter()
File
- modules/
panopoly/ panopoly_images/ panopoly_images.module, line 49
Code
function panopoly_images_form_alter(&$form, &$form_state, $form_id) {
// Remove some necessary image styles
if ($form_id == 'ctools_entity_field_content_type_formatter_styles') {
if (!empty($form['image_style']['#options'])) {
$styles_to_remove = array(
'apps_logo',
'apps_logo_small',
'apps_screenshot',
'apps_featured_screenshot',
'linkit_thumb',
'thumbnail',
'medium',
'large',
'media_thumbnail',
);
foreach ($styles_to_remove as $style_name) {
if (!empty($form['image_style']['#options'][$style_name])) {
unset($form['image_style']['#options'][$style_name]);
}
}
}
}
// Improve the media upload form
if (!empty($form['upload'])) {
$form['upload']['#size'] = 30;
}
// Warm the image style cache by preloading some images. This is needed when the images are
// added in the WYSIWYG so they will be fully rendered and can be sized on insert.
if ($form_id == 'media_format_form') {
$form['preload'] = array(
'#prefix' => '<div style="display: none">',
'#suffix' => '</div>',
);
$image_path = $form['#media']->uri;
$image_formats = array(
'panopoly_image_full',
'panopoly_image_half',
'panopoly_image_quarter',
);
foreach ($image_formats as $format) {
$form['preload'][$format] = array(
'#markup' => theme('image', array(
'path' => image_style_url($format, $image_path),
)),
);
}
}
// Set the default media style to be default
if ($form_id == 'media_format_form' && !empty($form['options']['format'])) {
$form['options']['format']['#default_value'] = 'default';
}
}