Skip to content

Instantly share code, notes, and snippets.

View chander-b's full-sized avatar

Chander chander-b

View GitHub Profile
@chander-b
chander-b / gist:a14156cca652c1f509cfde53c20bf5d6
Created September 17, 2024 09:18
How to Migrate from Video Embed WYSIWYG to Drupal Core Media

How to Migrate from Video Embed WYSIWYG to Drupal Core Media

  1. Enable the core Media module.
  2. Create a Media type for remote video called remote_video with a source field called field_media_oembed_video. (If you used a standard install, this media type should get created automatically. Otherwise, you'll have to create it yourself.)
  3. Configure your text formats to use the core Media Embed button and filter. You're probably using ckeditor4 if you're still using Video Embed WYSIWYG
  4. Video Embed WYSIWYG Update Hook
function my_module_install() {
@chander-b
chander-b / gist:792e703ab32f7f92d5f54e5f9d727765
Last active September 17, 2024 09:15
How to convert existing image fields into Media images

How to convert existing image fields into Media images

  1. Enable modules

Enable Media and Media Library modules. These modules are not enabled by default. Once enabled, you'll see several Media types.

  1. Create media image fields

For each image field create a media image. For example, my Article content type has the Social share image field, so I created the Social share image media field. media-image-fields

Drupal 8 Cheatsheet

Files, Images and Media

// Load file object
$file = File::load($fid);

// Get uri (public://foo/bar/baz.png)
$uri = $file->getFileUri();