Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since we can depend on ctools now (via file_entity). Let's use the plugin system to make augmenting media easier and cleaner.
Comments
Comment #1
becw CreditAttribution: becw commentedI'm going to work on this issue in a few minutes.
Comment #2
becw CreditAttribution: becw commentedHere's a patch that provides a CTools plugin type for media browser plugins. This affects #1224766: Remove default media browser and replace with a default view.
I'm not sure that this is the best way to implement a CTools plugin system. The plugins are classes, but are pretty limited. Given that this is mixing with FAPI/Render API, it might make sense to expect some sort of process method on the plugin class that gets automatically called if present, or to use procedural CTools plugins so that the plugin files are not a class + process function. Anyway, it's a starting point.
Comment #4
JacobSingh CreditAttribution: JacobSingh commentedWe should use studlyCaps
Hmm... I wonder if instead we should do something like
foreach ($params as $k=>$v) {
//convert 'false'/'FALSE' to FALSE and 'true' to TRUE
}
Just to not special case this one. All params should sent 0|1 or true|false.
dunt gettit... allow plugins to provide a list of enabled or disabled plugins? Isnt' that something provided by params?
Should we pass the params to the class constructor and make it a property.
silly 2space whitespace on empty line
Combine these into a single function with id = NULL as a 2nd param?
Comment #5
becw CreditAttribution: becw commentedEffulgentsia and I also reviewed this approach, and talked about:
use a new info hook name (to make current implementations ofhook_media_browser_plugin_info()
just not do anything, instead of actively break)These changes will hopefully help decouple the ctools plugin api refactoring from the views in the media browser patch.
Comment #6
becw CreditAttribution: becw commentedHere's a re-roll. I've addressed the comments from #4, and moved some stuff around per #5 (though I completely disregarded our comments on calling the old hooks--it's a pretty straightforward code move, and implementations of the old
hook_media_browser_plugin_view()
won't be run anyway.Comment #7
becw CreditAttribution: becw commentedWell, that patch had no bugs, but also no code. Try this one!
Comment #9
effulgentsia CreditAttribution: effulgentsia commentedJust a reroll for testbot. Still needs review. Working on that.
Comment #10
effulgentsia CreditAttribution: effulgentsia commentedSome minor cleanup plus the addition of the media_internet plugin. This looks good to go to me. Excellent work, becw!
Comment #11
effulgentsia CreditAttribution: effulgentsia commentedNeeds a reroll due to #1224766-30: Remove default media browser and replace with a default view being committed. Working on that now.
Comment #12
effulgentsia CreditAttribution: effulgentsia commentedHere it is.
Comment #13
Dave ReidShould we be using === here? Not sure.
+ * return $plugins;
+ * @endcode
Shouldn't we put this example inside the hook function body as an example?
Little confused as to why we're using 'edit' as an access argument here when it's not really being used.
Comment #14
effulgentsia CreditAttribution: effulgentsia commentedWith #13 feedback. Here's the patch, and also a diff between the #12 patch and this one.
Comment #15
Dave ReidThe only problem I ran into was that the 'Select which plugins are enabled for this field' wasn't adjusted to use the new hook. It was an easy fix so I'm committing this to 7.x-2.x:
http://drupalcode.org/project/media.git/commit/54822b1
AWESOME JOB!
Comment #17
drzraf CreditAttribution: drzraf commentedreopening after git annotating and found that this patch, commited as 54822b195 introduced this hunk.
Some facts:
create files
is a prerequisite for any use of the media widgetfile_entity
(#1904108: 'create files' permissions should not forbid creating file for a specific content type) to deal with the use of this permissionA sample use-case:
Consequence:
create files
for anonymousI believe
create files
is not granular enough as it applies to creating files both in the node-creation context and separately.Comment #18
Dave ReidPlease please follow issue queue etiquette and do not open long-closed issues. That permission was *not* added in this issue, so please file a separate, new bug report if you must.
Comment #19
drzraf CreditAttribution: drzraf commentedbut that permission started being used when this commit was pushed: