The browser window display is quite different than standard Drupal display. While I don't think we're going to be able to harmonize it completely with the rest of Drupal I do think we can make some progress in that direction. The patch here is intended as a conversation starting point- I do not think this is the complete solution but I think it does move somewhat in that direction:
* tabs are rendered as Drupal primary tabs
* a title is provided for what the browser is supposed to do
* tab content is wrapped more consistently with borders
* media items are rendered as a consistent height
It would be good handle the height of the modal display more dynamically rather than the fixed height that is set- simple_dialog has a good example of how to handle setting the height based on the height of the loaded content that we might want to borrow from. We may also want to consider adjusting the width of the modal so that we can handle smaller displays that 600px which is what is set in Drupal.media.popups.getDialogOptions
Comment | File | Size | Author |
---|---|---|---|
#56 | media_browser_mediafront_not_working.png | 11.73 KB | jgahunia |
#56 | media_browser_mediafront_working.png | 19.14 KB | jgahunia |
#52 | media-browser_cleanup-1881152-52.patch | 20.54 KB | arthurf |
#51 | media-browser_cleanup-1881152-51.patch | 17.33 KB | arthurf |
#50 | Screenshot_2_15_13_1_25_PM.jpg | 62.79 KB | arthurf |
Comments
Comment #1
arthurf CreditAttribution: arthurf commentedComment #1.0
arthurf CreditAttribution: arthurf commentedAdd the display of the image
Comment #2
arthurf CreditAttribution: arthurf commentedEdit: wrong issue. Too many tabs.
Comment #3
arthurf CreditAttribution: arthurf commentedSlight change to the first patch- opens the media browser with smaller vertical height to render the upload form more cleanly as that one is always displayed on open. I've made the browser narrower to force only 5 media items in a row which makes the display cleaner.
There needs to be a height fix when you use the pager on the media view to prevent the scroll bar from briefly appearing.
Comment #4
ParisLiakos CreditAttribution: ParisLiakos commentedi guess you should remove it:)
dont understand the reordering here
not much i can say about css
Comment #5
arthurf CreditAttribution: arthurf commentedAs per the order change- the libraries are loaded in order so if you want to override some of the default CSS from the jquery libraries it is much easier to have your library load after the others.
Comment #6
arthurf CreditAttribution: arthurf commentedRerolled patch without reference to missing CSS file.
Comment #7
ParisLiakos CreditAttribution: ParisLiakos commentedthats hard to read. why not wrap in single quotes, so there are no backslashes?
Comment #8
arthurf CreditAttribution: arthurf commentedThe double quotes are so that \n can be used for line breaks. I can add a . "\n"; if you don't like the escaped code but I do prefer that the resulting markup has line breaks.
Comment #9
ParisLiakos CreditAttribution: ParisLiakos commentedThen
+ $html = "<div id=\"media-dialog-tabs-wrapper\">\n";
could be
+ $html = "<div id='media-dialog-tabs-wrapper'>\n";
and
$html .= "<h2 id=\"media-dialog-title\">" . t('Select a file') . "</h2>\n";
to
$html .= '<h2 id="media-dialog-title">' . t('Select a file') . "</h2>\n";
Comment #10
arthurf CreditAttribution: arthurf commentedReroll
Comment #11
ParisLiakos CreditAttribution: ParisLiakos commentedI know you probably gonna hate me now..but:
theme_item_list
accepts atitle
argument.Why dont we pass
t('Select a file')
as a title in theme_item_list instead of addingtheme_media_dialog_tabs
? And along with that pass some class or#prefix
#suffix
for styling?Comment #12
arthurf CreditAttribution: arthurf commentedMakes tonnes of sense to me- less code is less code. Rerolled with just using item_list and a tweak to the css file, theme functions removed.
I should probably address the formatting of the views thumbnails so that they center and don't stretch.
Comment #13
arthurf CreditAttribution: arthurf commentedThis patch has a few tweaks to how the thumbnails are displayed in the browser. This needs to be checked against the admin view at admin/content/file/thumbnails.
Comment #14
bbinkovitz CreditAttribution: bbinkovitz commentedThis looks great, arthur. It doesn't necessarily look like the user's theme if they're not using Seven as their admin theme, or not using admin theme on add/edit pages, but it still looks nice and is very usable.
Comment #15
ParisLiakos CreditAttribution: ParisLiakos commentedFurther optimization!
Could be
Comment #16
arthurf CreditAttribution: arthurf commentedGood point, patch is rerolled with these suggestions.
In looking over some of this code, I think one issue with the CSS could be addressed by changing the dimensions in media_image_default_styles() to reflect what actually gets displayed. We could reduce the complexity of the code by making the display of the images just use the image dimensions rather that using CSS to size the image.
Also it seems like theme_media_admin_thumbnail() is never being called- media_preview_ajax() is the only function that I see that references it but I couldn't find any reference to that function either. Though removing these are probably beyond the scope of this issue they are connected to the display of the thumbnails so it's worth noting.
Comment #17
ParisLiakos CreditAttribution: ParisLiakos commentedclass should be an array too..
thanks
agreed
Comment #18
arthurf CreditAttribution: arthurf commentedRerolled the CSS to not be height/width specific. Note that this will now show all the media thumbnails at the size specified by square_thumbnail. We may want to consider changing the dimensions in the image style.
Comment #19
arthurf CreditAttribution: arthurf commentedComment #20
ParisLiakos CreditAttribution: ParisLiakos commentedyeah, we should make it 100x100..i have no clue why it is 180x180 now
Comment #21
arthurf CreditAttribution: arthurf commentedThat last diff does set it 100x100- forgot to set it back after testing. If we do include it at this size we should consider running an image style flush. It is somewhat of an issue because somebody may have used this image style elsewhere. We could also write an update function that has code similar to media_update_7206 to create a new style. I'm not sure of what the best route to go is here.
Even if the image style has be reused elsewhere the admin could just go and reset the configuration and flush the image style again. We could make a upgrade note about this and leave it at that. Though it'd be nice to rename "square_thumbnail" to "media_preview" or something that is a bit more specific for what it is used for.
Comment #22
ParisLiakos CreditAttribution: ParisLiakos commentedUgh, sorry didnt see the patch and checked the style without clearing cache after applying and was @180.
Well i dont see the need to do anything more than adding just a cache clear for image styles in an update function and right after that returning a message stating that the image style has its dimensions changed to make admins aware of the change
EDIT: btw found this in @todo of API.txt:
rename image style square_thumbnail to use the media_ namespace
Comment #23
arthurf CreditAttribution: arthurf commentedHere's a reroll with an update to flush the old square_thumbnail and changing the db name to media_thumbnail if it is in the db because it has been overridden.
Comment #24
arthurf CreditAttribution: arthurf commentedWoops- here's a reroll with the name change in the install function.
Comment #25
ParisLiakos CreditAttribution: ParisLiakos commentedMaybe the update function docblock could include the dimension information..eg Flush image styles cache to use the new
forgot a b ^^
Comment #26
arthurf CreditAttribution: arthurf commentedUgh. Reroll
Comment #27
aaron CreditAttribution: aaron commentedWhen I apply this patch, on an existing system, the icons for pictures are enlarged to 1024x768, although the derivatives are correct (square_thumbnail). This is after clearing the cache, by the way.
Comment #28
arthurf CreditAttribution: arthurf commented@aaron- does the markup itself show the size this way? Does media_thumbnail show up in the list of image styles and is it set to 100x100?
Comment #29
aaron CreditAttribution: aaron commented<img width="2160" height="1440" title="" alt="" src="http://localhost/drupal/sites/default/files/styles/square_thumbnail/public/field/image/100_6177.JPG" typeof="foaf:Image">
The media_thumbnail preset is at 100x100, but is not being pulled into the browser, as you can see above.
Comment #30
arthurf CreditAttribution: arthurf commentedremoved
Comment #31
arthurf CreditAttribution: arthurf commentedUGH wrong issue, please excuse
Comment #32
arthurf CreditAttribution: arthurf commented@aaron so I think this was because your display style had the square_image in its setting. I'm not clear as to why mine didn't- I tested a clean install and an upgraded install- but I think this new patch fixes it.
Comment #33
aaron CreditAttribution: aaron commentedthis looks like it will work. I was trying to something similarly last night. A possible issue that I see is if people are using square_thumbnail with other display modes. I will try to take a look later today.
Comment #34
aaron CreditAttribution: aaron commentedHere, this will solve that specific issue.
Comment #35
arthurf CreditAttribution: arthurf commentedThe issue now is that non-image content in the browser does not have height and width settings. My approach is to look at elements that are not using the image_style theme function, extract the current height/width settings for the media_thumbnail image style and try to apply those to the non-image content. I'm also trying to use the icons that are provided with media to render those instead of the core icons. This is a bit ugly, but it provides a better UX I think. We'd probably want to make an icon for pdfs or figure out a nicer way to decide what file we want to display. My code is really proof of concept.
This patch takes the changes from #34 and takes the patch from #1743040: "You have not selected anything!" error message, when a selection has clearly been made. The main difference here is a significant refactor of theme_media_thumbnail().
Comment #36
Dave ReidNote, the 180x180 size rather than using what's actually displayed with 100x100 comes from there was the intent to be able to have a slider to enlarge or shrink the thumbnails in the library tab. See #1024844: Media thumbnails are shrunk from 180px to 100px.
Comment #37
arthurf CreditAttribution: arthurf commentedI defer to others on this but it seems to me like zoom functionality (while awesome!) is a feature maybe beyond the core functionality of media. A module implementing zoom functionality could use hook_image_styles_alter() to change the default size and then apply the JS.
If people feel otherwise we should probably then increase the dimensions and set the js slide code to start at a lower res. Alternatively, we could provide a second style with larger dimensions and add an image_style url as a data attribute to the thumbnail. When the zoom action starts we can swap the the src value on the image with the larger image style.
Comment #38
arthurf CreditAttribution: arthurf commentedI cleaned up this patch a bit. I'm still not thrilled about how theme_media_thumbnail() is working but I think it's cleaner than it was. I've moved the resizing code into theme_media_formatter_large_icon() which will then match the sizing that media_thumbnail specifies. Maybe this is overkill at this point- at worst this patch improves the markup and label handling in theme_media_thumbnail()
Comment #39
arthurf CreditAttribution: arthurf commentedReroll against head
Comment #40
aaron CreditAttribution: aaron commentedThis works great now!
Comment #41
ParisLiakos CreditAttribution: ParisLiakos commentedWell those statics inside the theme functions is pretty ugly..so i tried to find a better way..in the process i found 2 functions that are not being used
media_file_type_info_alter
media_file_type_media_default_view
Also: no need for static in theme_media_formatter_large_icon.image_style_load() takes care of it, so there is no performance hit, with just an extra function call.
For other files that do not display as images, we cant do anything. Settings of all file types under the preview mode, should only have
Large filetype icon
checked..If the site builder changes that (he/she gets a nice big warning when visitsadmin/structure/file-types/manage/*/file-display/preview
, then he/she is on his/her own).For undefined file types i added media_file_displays_alter() which forces them to go through
theme_media_formatter_large_icon()
Comment #42
ParisLiakos CreditAttribution: ParisLiakos commentedeven better. moved
image_style_load()
over atmedia_field_formatter_view()
Comment #43
aaron CreditAttribution: aaron commentedIt looks great. Thanks a lot!
Comment #44
gmclelland CreditAttribution: gmclelland commentedJust tested this on simplytest.me. Here is a quick review:
I think #1898090: Modal iframe is off by a few pixels needs to be committed before this gets in to fix the centering (it's subtle).
It seems like the tabs and the text inside the tabs change size when you click on them.
When I change the media browser theme to Bartik, it looks messed up for some reason. (See attached) Will other themes need to accomodate to these changes? ex. Rubik, Bartik, etc?
Great job with what you have done so far.
Comment #45
gmclelland CreditAttribution: gmclelland commentedForgot the attachment.
Comment #46
arthurf CreditAttribution: arthurf commented@gmclelland - yes- clicking the tabs does make them shift- the active tab's text wasn't bold. Attached patch fixes that. As per other themes, wow, looks like there is some work to do.
Comment #47
arthurf CreditAttribution: arthurf commentedI've been messing around with support for multiple themes and I think this is a larger issue than I'd hoped. My original approach was simply adding some classes to the tabs so that they render out the same way the theme does. This works for some themes, though not for bartik because the jquey.ui.tabs.css adds css which ends up overriding/altering the display of the core theme styles. I don't really see a way around this except for only including the the jquery.ui.tabs.min.js and not the css. Doing this improves the situation but the theming still isn't quite right because the structure of the elements is different than what the theme expects.
So I tried to get around this by trying to emulate the display of theme_menu_local_tasks() to render the tabs which definitely improves things but it is likely the case that unless we really try to create the output of the media browser to approximate the standard page elements it's not going to fare well cross theme.
I see three approaches to move forward:
* only officially support the seven admin theme, continue our semi-integrated/semi-custom approach
* try to replace as many elements in the media browser with standard drupal elements and override the jquery.ui.tabs.css or get rid of it all together
* abandon jquery tabs all together and use standard drupal page elements with custom JS to handle the tabs. This actually turns out to be quite simple to do- I added some data attributes to the existing markup and wrote this JS as a proof of concept.
There would need to be some cleanup in terms of error handling but it does work. I'm not sure if it is a viable way forward, I'm just trying to figure out how to improve the sustainability of display inside the browser.
Thoughts?
Comment #48
ParisLiakos CreditAttribution: ParisLiakos commentedin my opinion, we should not ditch jquery ui tabs..i prefer relying on it, than have to maintain our own custom code..
and for css, it is, we either
i think thats what we should decide here..solution 1 is what we were doing till now, solution 2 is what this issue try to achieve...
and seems that solution 2 sucks for other admin themes..so lets just stick to what we have now, with the applied cleanup we already did
Comment #49
arthurf CreditAttribution: arthurf commentedUnfortunately option 1 doesn't really work with all themes because of different kinds of assumptions about markup. I'm going to take another shot at rendering the tabs through media_local_tasks and overriding the jquery.ui css where I can. It is also worth considering removing some of the classes when the tabs are triggered.
Comment #50
arthurf CreditAttribution: arthurf commentedI've done a bunch of cleanup here that I think is a starting point for improving things further. The stuff in media_browser() adds a degree of complication but I was trying to make it easier to get things into Drupal elements. I'm still privileging the Seven theme but Bartik is no longer terrible.
I think it might be worth considering breaking some of this work out into templates so that it is easier for other themes to override- that maybe the simplest solution for theme maintainers.
Comment #51
arthurf CreditAttribution: arthurf commentedOk, here's another crack at this. Moves some of the display code into the browser template, cleans up some JS. Spruces up the display type screen as well.
Comment #52
arthurf CreditAttribution: arthurf commentedHere is a slight cleanup of the above.
Comment #53
aaron CreditAttribution: aaron commentedThis looks great to me.
Comment #54
ParisLiakos CreditAttribution: ParisLiakos commentedI removed check_plain from attributes (drupal_attributes pass everything through it already so no need) and committed it
Congrats and thanks arthurf for pushing this, seems a lot nicer!
http://drupalcode.org/project/media.git/blobdiff/b433b278d7e0ab7420f5a87...
Comment #56
jgahunia CreditAttribution: jgahunia commentedHi All,
New to the community so forgive any miscommunication's.
This particular fix seems to break the mediafront preview display in the media browser.
See attached files:
media_browser_mediafront_not_working.png (git commit 188b2e9)
media_browser_mediafront_working.png (git commit b433b27)
Regards.
Comment #57
arthurf CreditAttribution: arthurf commented@jgahunia I'm unclear on what in particular is broken for media front here? Is it that the preview for the media front item is constrained by the width of the preview size? While I really like that media front is providing a preview, the intent of the display in the media browser is thumbnails- perhaps a opening a modal with a preview would be a better bet?
Comment #57.0
arthurf CreditAttribution: arthurf commentedFixed broken image link