Entity Browser
Provides a generic, highly extensible entity browser/picker/selector that can be used in any context where selecting entities is needed.
entity_browser
インストール
composer require 'drupal/entity_browser:8.x-2.15'
概要
Entity Browserは、Drupalでエンティティを閲覧、作成、選択するための標準化された高度にカスタマイズ可能なインターフェースを提供する包括的なモジュールです。複数の表示オプション(モーダル、iframe、スタンドアロン)、エンティティ選択用の様々なウィジェットタイプ(Views、ファイルアップロード、メディア画像アップロード)、カスタマイズ可能な選択表示を備えた柔軟なプラグインベースのアーキテクチャを提供します。
このモジュールはエンティティ参照フィールドとシームレスに統合され、エンティティ選択体験を向上させる専用のフィールドウィジェットを提供します。複数ステップの選択ワークフロー、ドラッグ&ドロップによる並べ替え、カーディナリティ検証、コンテキストに応じたバンドルフィルタリングをサポートしています。Entity Browserは、メディア管理、コンテンツ編集ワークフロー、高度なエンティティ選択機能を必要とするあらゆるシナリオで特に有用です。
拡張性を考慮して構築されており、開発者は表示、ウィジェット、ウィジェットセレクタ、選択表示、フィールドウィジェット表示、検証用のカスタムプラグインを作成できます。また、選択プロセスの様々な段階で動作をカスタマイズするための包括的なイベントシステムも提供しています。
Features
- カスタマイズ可能なラベルとマシン名を持つ設定可能なエンティティブラウザインスタンス
- 複数の表示プラグイン:モーダルダイアログ、iFrame埋め込み、スタンドアロンページ
- エンティティ選択用ウィジェットプラグイン:Viewsベースの選択、ファイルアップロード、メディア画像アップロード
- ウィジェットセレクタプラグイン:複数ウィジェット間のナビゲーション用のタブとドロップダウン
- 選択表示プラグイン:作業中の選択ゾーンを持つ複数ステップ表示、即時選択用の非表示
- フィールドウィジェット表示プラグイン:エンティティラベル、画像サムネイル、レンダリングされたエンティティ表示
- 編集、削除、置換ボタンを備えたエンティティ参照フィールドウィジェット
- メタデータ編集(alt、title、description)を備えたファイル/画像フィールドウィジェット
- カーディナリティ検証とエンティティタイプ検証
- 選択されたエンティティのドラッグ&ドロップによる並べ替え
- カスタム表示プラグインと選択フォームフィールドを持つViewsとの統合
- Viewsでのコンテキストに応じたバンドルフィルタリング
- 編集モードでの事前選択のサポート
- カスタマイズ用のイベント駆動型アーキテクチャ
- AJAXベースのエンティティ選択用JavaScriptコールバック
- アップロード場所でのToken サポート
- ブラウザ内でエンティティを作成するためのInline Entity Formモジュールとの統合
Use Cases
Media Library Alternative
Create a custom media browser with Views-based media listing, upload widget for new media, and thumbnail previews. Use modal display for seamless content editing workflow.
Content Reference Field
Replace the default entity reference autocomplete with a visual entity browser. Configure a View showing content with images and use 'rendered_entity' display for rich previews.
Image Field with Gallery Selection
Use entity browser with file/image field widget. Configure multi-step selection display for reviewing selections before confirming. Enable drag-and-drop reordering.
Inline Entity Creation
Enable entity_browser_entity_form submodule and add 'Entity form' widget alongside View widget. Users can either select existing entities or create new ones without leaving the browser.
Contextual Entity Selection
Use the entity_browser_bundle filter and entity_browser_widget_context argument default to show only entities matching the field's target bundle configuration.
WYSIWYG Entity Embedding
Integrate with Entity Embed module to allow editors to browse and embed entities (media, nodes) directly from the WYSIWYG editor using entity browser.
Tips
- Use the 'Auto select' option on View widgets for single-click selection without needing to press a submit button
- Enable 'Selection hidden by default' in multi-step display for cleaner UI when selection area is not immediately needed
- Use the 'Replace' button option for single-value fields to allow quick replacement without manual remove-then-add workflow
- Leverage hook_entity_browser_view_executable_alter to pass contextual arguments to Views based on the current page
- Use different entity browsers for different use cases rather than one complex browser
- Test with entity_browser_example module enabled to see working configurations
- For better performance with large entity sets, use AJAX-enabled Views with pagination
- Consider cardinality when choosing between checkboxes and radios - the view widget auto-switches based on cardinality
Technical Details
Admin Pages 3
/admin/config/content/entity_browser
Lists all configured entity browsers. From here you can add new browsers, edit existing ones, configure widgets, or delete browsers.
/admin/config/content/entity_browser/add
Creates a new entity browser configuration with display, widget selector, and selection display settings.
/admin/config/content/entity_browser/{entity_browser}/widgets
Configure widgets for the entity browser. Add, remove, and reorder widgets that provide different ways to select entities.
権限 2
Hooks 9
hook_entity_browser_display_info_alter
Alter the display plugin definitions
hook_entity_browser_widget_info_alter
Alter the widget plugin definitions
hook_entity_browser_selection_display_info_alter
Alter the selection display plugin definitions
hook_entity_browser_widget_selector_info_alter
Alter the widget selector plugin definitions
hook_entity_browser_field_widget_display_info_alter
Alter the field widget display plugin definitions
hook_entity_browser_widget_validation_info_alter
Alter the widget validation plugin definitions
hook_form_entity_browser_form_alter
Alter any entity browser form (base form ID alter)
hook_form_entity_browser_ENTITY_BROWSER_ID_form_alter
Alter a specific entity browser form by ID
hook_entity_browser_view_executable_alter
Alter the view executable in the view widget before rendering
Troubleshooting 6
Ensure the Drupal AJAX dialog library is loaded. Check browser console for JavaScript errors. Verify the entity browser has a valid configuration.
Add the 'Entity browser select form' field to your View. This field must be present for selection to work.
Check cardinality settings. If using 'Edit selection' mode, ensure the selection display plugin supports preselection (use Multi step display, not No display).
Verify the 'Allowed file extensions' setting in the upload widget matches your requirements. Check PHP upload limits.
The entity_browser_bundle filter gets values from widget context. Ensure your field widget passes target_bundles in widget_context.
Check user permissions for 'access [browser_id] entity browser pages'. Verify the View has results and the display type is 'Entity browser'.
Security Notes 4
- The 'administer entity browsers' permission is restricted and should only be granted to trusted administrators
- Entity browser respects entity access - users can only select entities they have view access to
- File upload widgets inherit field-level validation for extensions and file size
- The edit button in field widgets checks entity update access before display