Problem/Motivation

Currently the 2.x version this module will attempt to embed any url to any provider in the provider repository

Often you don't want your filter to embed every type of url that has a provider. You probably want to restrict you filter to only use certain providers.

Soembed should have a setting on the filter instance to select which providers to enable.

Listing all the possible providers as checkboxes would make a huge list of items and a pain to manage.

Proposed resolution

The oembed_providers module (https://www.drupal.org/project/oembed_providers) allows admins to create groups of enabled providers (buckets)

If oembed_providers is enabled, soembed should list these buckets on the filters settings form, and only the providers enabled in the selected buckets should be embedded with the filter.

I have made a patch that attempts to do this.

If the oembed_providers module is not installed or no buckets are enabled on the filter, it defaults to the original behavior of embedding any url.

I've tested this with oembed_providers 2.x-dev

Issue fork soembed-3260982

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

loze created an issue. See original summary.

loze’s picture

Status: Active » Needs review
StatusFileSize
new6.45 KB
loze’s picture

StatusFileSize
new10.94 KB

This patch cleans it up a bit as well as adds a setting to bypass core medias embed frame and optionally add the embed code directly.
This also fixes #3199585: Notice: Undefined offset: 3 in Drupal\soembed\Plugin\Filter\SoEmbedFilter->embed()

loze’s picture

Version: 8.x-2.0-beta1 » 8.x-2.0-beta2
StatusFileSize
new10.3 KB

wasn't applying any longer, rerolled for beta2

Webbeh’s picture

Would love to see this included - oembed_providers is a great addition.

loze’s picture

Version: 8.x-2.0-beta2 » 8.x-2.0-beta3
StatusFileSize
new9.88 KB

heres a reroll for beta3

loze’s picture

StatusFileSize
new6.1 KB

The previous patch had the schema config in the wrong directory. I also removed the code I had in there from #3 to bypass core medias embed iframe which is out of scope of this issue and I will raise in another issue.

This patch allows you to configure the oembed_providers buckets used for each input filter.

  • Ki committed 0843f020 on 8.x-2.x authored by loze
    Issue #3260982 by loze: Allow using oembed_providers bucket configs per...
loze’s picture

Thanks for committing this.

After using it for a while I noticed that if there are many urls in the field ,and some are not oembed urls, or some are dead urls that go nowhere, the call to getProviderByUrl() still attempts to ping the url even if its not in the provider repository. This causes a big performance hit when filtering the text.

We should have our own method in the filter that checks if the url is a known provider and return early if it is not.

I have a follow up patch for this coming.

loze’s picture

I don't think I did this right. Im still trying to get a hang of the issue forks on here. I was trying to post these changes

https://git.drupalcode.org/issue/soembed-3260982/-/commit/c4f42eda18492a...

Not sure where I went wrong. My apologies for the mess.

This adds a private method to the filter for getProviderByUrl() that only checks the known providers without trying to get the url.

ki’s picture

Could you make a cleaned-up MR or post a patch file?

Thanks.

loze changed the visibility of the branch 8.x-2.x to hidden.

loze’s picture

Version: 8.x-2.0-beta3 » 8.x-2.0-beta5
loze’s picture

Sorry about all that. Here is a patch.

loze changed the visibility of the branch 3260982-check-known-providers to hidden.

  • Ki committed 01bfad16 on 8.x-2.x authored by loze
    Issue #3260982 by loze, Ki: Allow using oembed_providers bucket configs...
ki’s picture

Status: Needs review » Fixed

Released in 8.x-2.0-beta6

ki’s picture

Status: Fixed » Closed (fixed)