Problem/Motivation

Core has experimental Media since 8.x-4: #2831274: Bring Media entity module to core as Media module.

More detailed changes:
https://www.drupal.org/node/2863992
https://www.drupal.org/node/2825215#followup-roadmap

We may have to postpone this for now till Media things are settled enough to work with.
We may need to create a new branch to cope with potentially drastic changes.

Feel free to update issue summary if you are following core Media closely.

Proposed resolution

  • Adapt, adjust, and or update to core changes.
  • Create a new branch to accommodate changes against 8.x-4.

Remaining tasks

  • @todo: List remaining tasks here.

User interface changes

Blazy is mostly dealing with cosmetics, and mostly optional integration, too, there might be none.

API changes

Blazy is mostly dealing with cosmetics, and mostly optional integration, too, there might be none.

Data model changes

Blazy is mostly dealing with cosmetics, and mostly optional integration, too, there might be none.

CommentFileSizeAuthor
#8 2881849-8.patch672 byteswrd
#5 2881849-5.patch5.43 KBwrd

Comments

gausarts created an issue. See original summary.

gausarts’s picture

Issue summary: View changes
wrd’s picture

I'm running into the following error in 8.4-rc2:

Fatal error: Call to undefined method Drupal\media\Entity\Media::getType() in /drupal84/docroot/modules/contrib/blazy/src/Dejavu/BlazyVideoTrait.php on line 174

gausarts’s picture

Thank you for the report.

We may need to do a switch for this particular issue to support both Media entity and Media in core at D8.
We can also create a new branch if changes are many. But if one or two, we can do a switch instead.

In your mentioned issue, we simply need to switch getType() for getSource().
The relavant changes to look for:
https://www.drupal.org/node/2863992

wrd’s picture

StatusFileSize
new5.43 KB

I think I've got it fixed, thanks for the info. I'm not at all sure this is the most efficient way to fix it; if you have an alternate suggestions, let me know. Thanks!

gausarts’s picture

Category: Plan » Task
Status: Active » Needs work

Thanks for the heads up.

Changed to Task to adopt the patch without another thread ;)

I didn't see any change to Field API in regards to getType() method:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21F...
vs.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21F...

Perhaps you can leave Field getType() things as before. No need to check for a getSource() at field classes.

We can focus on things which affect Media entity methods.

The one needs changing seems just this line:

-    $config = $media->getType()->getConfiguration();
+    $config = method_exists($media, 'getSource') ? $media->getSource()->getConfiguration() : $media->getType()->getConfiguration();

I haven't thoroughly checked this, nor any other thing related to Media changes, though.
Please let me know if you see any issue with your one-liner change only above? Thanks.

wrd’s picture

Ah! Thank you. I'll fix that up and upload a new patch.

wrd’s picture

StatusFileSize
new672 bytes

OK, here's a new patch. I'll let you know if I run into any more issues. Thanks again for the help!

cbeier’s picture

Status: Needs work » Needs review

Yes, I have also only the getType() change found. The blazy module, with the blazy module works fine, with the patch from #8.

Christopher Riley’s picture

Thank you for the patch now I can finally do some testing. Would be nice to see this get committed.

rajab natshah’s picture

Status: Needs review » Reviewed & tested by the community

Patch #8 is working.
Thank you.

camilo.escobar’s picture

Patch #8 works pretty well.
Thanks.

grimreaper’s picture

Hello,

Patch from comment 8 fixed the issue.

Thanks.

imclean’s picture

Status: Reviewed & tested by the community » Needs work

The blazy module seems to have a hard requirement of video_embed_field for media entity views. blazy.views.inc includes the following:

  if (function_exists('video_embed_media_media_bundle_insert')) {
    $data['media_field_data']['blazy_media'] = [
      'title' => 'Blazy',
      'help'  => t('Displays a preview of a Media using Blazy, if applicable.'),
      'field' => [
        'id' => 'blazy_media',
        'click sortable' => FALSE,
      ],
    ];
  }

The function video_embed_media_media_bundle_insert() exists in a sub module of Video Embed Field 1.x, which works with the contrib module media_entity. VEF 2.x works with core's media module but doesn't contain that function.

I'm also not sure why video embed field should be required for media entity views integration if only images are required.

imclean’s picture

We're being encouraged to use media entities instead of file fields directly. Blazy supports file fields but not entity reference fields for media entities.

For example, a new site wanting a "gallery" field would have an entity reference field to reference media entities. The field widget can be an entity browser with a number of widgets for selecting existing entities or creating new ones.

The "Blazy" display formatter is currently not available for this field.

Edit: An example of how it's being tackled with Photoswipe: #2977943: Support Media and Entity References

seanb’s picture

Most modules create a new branch to integrate with media in core. This avoids complexity and in the end media_entity contrib is now unsupported.

We're being encouraged to use media entities instead of file fields directly. Blazy supports file fields but not entity reference fields for media entities.

That is true, however in this case you would configure blazy for you image field in your media type. The node shouldn't have to care about this, which would make it a bit easier I guess?

imclean’s picture

True. As usual there are a number of ways of doing things. Blazy directly supports gallery modules such as Photoswipe and colorbox as well as carousels with the slick media module.

Each media entity could have a single value image field, which makes it easier for entity browsers. The content type then has a multi value entity reference field to the media entity. In this case the gallery/carousel would be within the node while blazy would be used for loading individual images. This could work but would bypass Blazy's support for the gallery style modules.

It also doesn't avoid the problem in #14.

geek-merlin’s picture

Priority: Normal » Major
Status: Needs work » Reviewed & tested by the community

The issue raised in #14 has its own number: #2997224: Update to support Video Embed Field 8.2.x
The patch there needs review, blink blink.

So re-setting patch in #8 to RTBC due to #11.

Raising prio cause WSOD.

  • axel.rutz committed 25fa29a on 8.x-1.x authored by wrd
    Issue #2881849 by wrd: Integrate with core Media 8.4
    
geek-merlin’s picture

Title: Integrate with core Media 8.4 » WSOD with media in core
Status: Reviewed & tested by the community » Fixed
Related issues: +#2999198: Roadmap for core Media integration, +#2999196: Blazy views formatter gone

Hmm, this issue relly needs some cleanup.
So:
* Retitling for the issue fixed
* If this is the only problem we will NOT need a separate branch (only if the need arises)
* If this is the only problem we will NOT need a plan issue, but will open one if the need arises
* Opened #2999196: Blazy views formatter gone to tackle #14
* Opened #2999198: Roadmap for core Media integration to tackle #15

SO closing this for now.

gausarts’s picture

Thank you!

Status: Fixed » Closed (fixed)

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

alison’s picture

Hi, and thank you!!!!!!!!!! Just verifying, the fact that #8 is included in latest RC, as was #4 over on #2997224: Update to support Video Embed Field 8.2.x, that means Blazy works fine with Media in core, yes...? (checking b/c project page still says otherwise -- which is fine, not blaming you, just checking!)

Sincerely yours,
Overly-anxious person working on a "media in core" upgrade :) :)