- Merge request !3Issue #3281357: Add ability to modify the embed options β (Open) created by unstatu
- last update
over 1 year ago 5 pass - πͺπΈSpain tonibarbera
Here a patch for the url_embed version 2.0.0-alpha1
- last update
over 1 year ago 5 pass - last update
over 1 year ago 5 pass - Status changed to Needs work
over 1 year ago 10:05am 4 January 2024 - π¨πSwitzerland berdir Switzerland
Open to that, but this should use a ->alter(), not invokeAll() and the hook needs to be documented.
- πͺπΈSpain unstatu
Thanks @Berdir. I have updated the patch to use the ->alter() method. Good point.
Where should I document the hook usage? In the readme file?
- πΊπΈUnited States mark_fullmer Tucson
Where should I document the hook usage? In the readme file?
I've added a documentation guide for this module, and added a page dedicated to modifying and extending the code:
https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... β
Let's add documentation of this alter hook there.
- πΊπΈUnited States mark_fullmer Tucson
I've updated documentation at https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... β
However, per https://www.drupal.org/docs/develop/standards/php/api-documentation-and-... β , this should also be documented in an url_embed.api.php file.
Leaving this as "Needs work" for that code change.
- Status changed to Needs review
11 months ago 10:25am 7 June 2024 - πͺπΈSpain unstatu
Thanks @mark_fullmer for the feedback and for writting the documentation. I have added the url_embed.api.php file with the documentation.
- Status changed to Fixed
11 months ago 7:52pm 7 June 2024 - Status changed to Needs work
11 months ago 7:54pm 7 June 2024 - πΊπΈUnited States mark_fullmer Tucson
Okay, great! I think this now should be set to merge into the 3.x branch, rather than 8.x-1.x. I've changed that on the merge request. Can you resolve the merge conflict?
- First commit to issue fork.
- πΊπΈUnited States mortona2k Seattle
Rebased onto 3.x.
Included dependency injection for ModuleHandler to assist with https://www.drupal.org/project/url_embed/issues/3488449 π Replace \Drupal calls with dependency injection Active
This hook is included in the documentation, so there should either be a link back to this issue for the patch or we should provide a release with it included.
--
As an aside, when I did the rebase, git got hung up on one of the commit messages starting with #, IE #3281357 for the commit number.
I have no idea why that happened, and for only one of the commits, but I had to remove the # to get it to register the commit message.
There was a conflict on this commit, and it opened in vim for editing. I'm not sure if one of those has to do with reading a line starting with # as an empty line. If so (maybe this is related to editing the message for a conflicting commit), how would I accept the existing message starting with #?
(You can see the last commit in this list doesn't start with #: https://git.drupalcode.org/project/url_embed/-/merge_requests/23/commits)
- πΊπΈUnited States mortona2k Seattle
The hook works, but doesn't do what I as looking for.
Maybe this is a misunderstanding on my part, but I was thinking that this would allow modifying the oembed response.
In the case for Codepen, the response is: https://codepen.io/api/oembed?format=json&url=https://codepen.io/mortona...
I was thinking this would allow modifying the attributes on the iframe, for example.
- πΊπΈUnited States mark_fullmer Tucson
Maybe this is a misunderstanding on my part, but I was thinking that this would allow modifying the oembed response.
Would this alter hook achieve what you wanted if $url was also pass-by-reference, as in:
$this->moduleHandler->invokeAll('url_embed_options_alter', [&$url, &$config]);
- πΊπΈUnited States mortona2k Seattle
That would let me change the url entered by the user.
I was looking at modifying the iframe response:
<iframe id="cp_embed_ZVYeqL" src="https://codepen.io/mortona42/embed/preview/ZVYeqL?default-tabs=js%2Cresult&height=900&host=https%3A%2F%2Fcodepen.io&slug-hash=ZVYeqL" title="Calendar" scrolling="no" frameborder="0" height="900" allowtransparency="true" class="cp_embed_iframe" style="width: 100%; overflow: hidden;"></iframe>
I am trying to debug an issue where I should be able to use height=900 in the url, and that is used for rendering. You can see it above, but that's from going directly to the url endpoint.
What I was actually trying to modify is the $embed, after $embed->get($url).
When I inspect this, I see the api response in oembed->data, but it doesn't have my height setting.
- πΊπΈUnited States mortona2k Seattle
What I'm looking for may be an extension of this issue.
Currently, we can only enter a url, and it will just display the response.
I would like it to show a form to edit the attribute values or html snippet before it is inserted.
Maybe a plugin to define the form and changes to the response.
I tried Embedded Content β , which allows you to do that by defining a plugin. I'm able to customize a form for the codepen embed options, and it works pretty well. That module is not oembed specific, but my plugin uses the core services for it.
Posted the plugin/codepen support here: https://www.drupal.org/project/codepen/issues/3496793 β¨ Support WYSIWYG embedding Active
- Status changed to Needs review
about 2 months ago 10:44am 7 March 2025 - First commit to issue fork.
- πͺπΈSpain akalam
I'm adding a commit allowing to alter the url, as suggested at #18, as I'm having also the same need
- First commit to issue fork.
- πͺπΈSpain xito
I get the following error after applying MR changes
Deprecated: Optional parameter $config declared before required parameter $module_handler is implicitly treated as a required parameter in /var/www/html/web/modules/contrib/url_embed/src/UrlEmbed.php on line 42
Code modified on the issue fork and generated the patch