There is a lot of information presented in the formatter summary text. We've done some cleanup to improve the information that is shown, the order of the data, and also make the style of it more consistent with what is seen for other Drupal formatters.
We also made two other changes:
* Moved the recently added Preview Image format information inside the conditional checking if the preset is set. It really shouldn't be displayed unless there is a preset selected. (Although we did wonder, shouldn't the formatter display the "default" preset information if no preset has been selected? It doesn't do this now. Let me know what you think is the right approach and we can change this patch if necessary.)
* Changed the second definition of $settings to be $preset_settings. The $settings variable is set at the top of the function, and this format is typical for Drupal hook_field_formatter_settings_summary functions. Elsewhere in the code, the settings for the preset is set to be $preset_settings. We made this change for sake of consistency.
Please note, this patch includes options for Sharing and Mute settings. There is another patch that we will be posting in a bit that includes these new options for the module. Trying to include the formatters in the other patch was going to be very messy, so they have been left here. Therefore "Sharing" and "Mute" will not be shown on the formatter display without applying this patch first.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | jw_player-remove_string_formatting-2713687-17.patch | 1.92 KB | sgdev |
| #9 | jw_player_formatter_settings.png | 38.98 KB | sgdev |
Comments
Comment #2
sgdev commentedPatch is attached for review. Thanks!
Comment #3
sgdev commentedHere is a link to the patch that adds the Sharing Sites and Mute options for JW Player: https://www.drupal.org/node/2713701
Comment #4
sgdev commentedOne additional comment... our original version of this patch moved the following functions into a
jw_player.formatters.incfile:We've seen this done on several other modules, and helps to improve readability. However we didn't want to confuse the updates we made by introducing a file that replaces existing functions.
Let me know if you'd like to eventually do this, and we can create another patch after these have been committed.
Comment #5
berdirI like to keep some spacing when using explicit weights. E.g. 0 ... 5 ... 10. Otherwise, if you ever want to add a new option, you have to move them all around again.
The other approach would be to move the fields into the proper order instead of relying on #weight. Would make the patch a lot bigger, but if we try to keep other changes in the settings form as minimal as possible, then I'd be OK with that.
Not exactly sure what you mean with not showing when default is selected.
You mentioned something about sharing, I think that's the part for showing it, but it's not actually in yet?
Btw, have you seen https://www.drupal.org/project/jw_player_sharing? It's linked on the project page. I have no idea what it does exactly, never used it. I'd also be OK with including that feature in the main project, it hasn't been updated in a long time and is possibly obsolete anyway.
Can we somehow find a way to combine those 4 settings into single point? e.g. 600x400 is obvious that it is fixed, while a response aspect ratio could be shown like 60% width (16:9)?
I think the code is trying to be more generic now than it has to be, see also below.
This is a similar problem. You can't really "translate" this string.
As mentioned above, Maybe we can simplify it by avoiding trying to be so generic with nested loops and switch statements. Just have a bunch of if isset($preset_settings['some_key']) { add a summary line for that setting/group of settings. Then we can have a fixed order based in importance, should get a lot easier to understand the code. might even be less code in the end.
In 99% of the cases, all those non-plugin based keys are always present anyway as you fill out the form and submit all form elements.
As an additional idea, we could move everything that's just based on the preset into a helper function. If someone ever wanted to show a similar summary (We could for example show it on the preset overview..?), then it would be easy to re-use.
I'm also open to leaving out some keys that we don't consider worth showing in summary. if you need to know details., the form is now two clicks away.
Maybe this could be combined into a single string too, something like Preview: @field_label (@image_style), Image style should probably show Original if not set, as that's what we'd show I think.
Comment #6
berdirOne more idea to make it more compact: Show the true/false cases as a list of options: "Enabled options: Autostart, Mute, Controls" or so.
Comment #7
sgdev commentedGood idea.
This is actually what we did initially, but then I started to get concerned it was difficult to follow the changes. We also started seeing some weird things happening when applying the patch. Git couldn't find lines as context since just about everything was changed. Maybe as a first step we can get it implemented with the
#weight, and then as a follow-up reorder them?Ok, I believe I might have been overthinking it. The default preset in code is 640x480 with autostart = false. However when a preset is assigned through a field formatter, the user has to select something... "none" isn't an option. (So if this is the case, why is there a
$default_settingsanyway?)Had not seen it, but looking at the code I have no idea how that would work with the newest versions of JW Player. Also what we've created is much more user friendly... not only can a user select what options they want, but can re-sort the order in which they are displayed using a Drupal draggable table.
Sure, I think we could do that.
Realized this might be an issue after seeing the feedback on the previous patch. Will definitely fix this.
Yes, let's create a new patch incorporating these ideas and get a new version for your review. Thanks for the feedback!
Comment #8
sgdev commentedI like this idea, very good.
Comment #9
sgdev commentedAttached is an updated patch for review, and also an image of how it looks on the screen.
The patch now includes a
jw_player_preset_settingshelper function that returns formatted preset information. Also a block of code has been reordered to avoid the need for#weights.Let me know what questions you have, thanks.
Comment #10
berdirNice, I like that output. Feedback below, mostly on translatability, also I think we can simplify the function a bit.
similar as below, try to get full sentences into t(), not just the prefix. So, something like t('Preview: @label (@image_style)'), no need for a context then I think, pretty specific at that point.
Do we really need that kind of flexibility?
It looks like you currently call it separately so you can put some other things inbetween.
What about just return the full array, always? Should simply the function quite a bit.
What we could do is use keys in $summary, e.g. $summary['skin'] = ..
Then if you really only want something specific, you can pick it out from that array?
Hm. This is tricky stuff for translation, very dynamic. Neither stretch options nor things like width are translatable now.
What happens if no stretching option is given explicitly? we could just fall back to that in that case I think, then we can always display something and it becomes less dynamic.
Then, maybe we can do two t() calls on the settings, something like
if (responsive) {
t('Dimensions: @width% width (@ratio), @stretching)
}
else {
similar t() hre.
}
the stretch options can then be t()'d on their own.
t()
What about leaving this out for now and instead adding it in the issue that adds this feature?
I would recommend to just have a function that returns a list of sharing options with a key and a label. Then this can be simplified to 1-2 lines or so:
$sharing_sites = array_intersect_key(jw_player_sharing_sites(), array_filter($preset_settings['sharing_sites_show']));
And then you just have to sort and implode.
Comment #11
sgdev commentedNew patch attached for review. I think we've addressed all of your feedback.
Regarding the dimensions/stretching, we've separated it into each possible option. I think that's the best way to address the translation concerns.
As for the Sharing formatter, I hope you can understand we're trying to actively manage multiple patches simultaneously. The formatter functions are being entirely rewritten. If we included Sharing (and Mute) in the other patch, it's not going to apply correctly once this one is committed.
Sharing and Mute are in the next patch, and the formatters are currently skipped if nothing is set. If we can get this patch committed relatively soon, the Sharing and Mute functionality will be next, and we can make any changes to the formatter if necessary.
Thanks.
Comment #12
sgdev commentedOk, this is getting a bit confusing... we have a new patch for https://www.drupal.org/node/2713701, but because the preset source option will be on the settings form, there are extra changes necessary for this patch.
However, because this patch is not yet ready to be committed, we can't create a patch for #2713701 that can actually be applied.
Let me know how you want to proceed... hopefully we can get this patch ready for commit fairly soon, or could combine the two patches into one larger patch. Thanks.
Comment #13
sgdev commentedI should mention on this thread since I did on the other, that this patch (https://www.drupal.org/node/2713701#comment-11133595) now includes all the updates in patch #11 above. Perform a diff between the two files and you can see the overlap.
We were going to run into a number of commit conflicts if they were not combined. Please review and let me know your feedback. Thanks.
Comment #14
berdirWould be very helpful if you could provide interdiffs: https://www.drupal.org/documentation/git/interdiff (that has various options, I just have a branch per issue and I'm diffing against the previous commit to get the interdiff).
That makes it way easier for me to review just the changes since the last patch.
The other patch is in, this needs a reroll.
This function looks easier already, I think we can also avoid this? If someone needs a string, they can just to that implode themself?
We tried to get rid of functions in Core that can return either a string or an array depending on an argument.
Comment #15
berdirI noticed that this feature also got lost in 8.x, opened #2716625: Re-add "Check Media support" feature to add it back.
Comment #16
sgdev commentedNot sure if you saw my comment in #13, but the patch committed for Issue #2713701 includes the code in patch #11 above. So essentially #2713687 and #2713701 were committed at the same time. Nothing for us to reroll.
We will create a new patch that adjusts for the comment made in #14. Thanks.
Comment #17
sgdev commentedPatch is attached for review. Thanks.
Comment #19
berdirThanks. I think we can take care of this in #2713701: Add preset sources, sharing, mute and validation for the 8.x port.