On Github brandonneil / media-getting-started
Brandon Neil / @brandonneil Web/Mobile Application Developer The University of Iowa
Fieldable files with a common media browser.
/** * Implements hook_views_default_views_alter(). */ function MODULENAME_views_default_views_alter(&$views) { if (isset($views['media_default'])) { // Add a header with help text $views['media_default']->display['default']->display_options['header']['area'] = array( 'id' => 'area', 'table' => 'views', 'field' => 'area', 'empty' => TRUE, 'content' => '<p>The Library feature allows you to select and embed existing images. You may also link to documents, such as PDF and Word. To upload new media to the Library, click the Upload button above. </p> <h2>To embed an image:</h2> <ul><li>Search for the file name using the filter or index below and then select by clicking on the displayed file</li> <li>Click the Submit button</li></ul>', 'format' => 'filtered_html', 'tokenize' => 0, ); } }
/** * Implements hook_media_wysiwyg_allowed_view_modes_alter. */ function MODULENAME_media_wysiwyg_allowed_view_modes_alter(&$view_modes, $file) { // Relabel some options switch ($file->type) { case 'document': $view_modes['default']['label'] = t('Original (Link to file)'); break; case 'image': $view_modes['default']['label'] = t('Original (As uploaded)'); $view_modes['full']['label'] = t('Large (Scale 480x480'); $view_modes['teaser']['label'] = t('Medium (Scale 220x220)'); break; } // Unset the preview view mode unset($view_modes['preview']); }