#20410 closed enhancement (fixed)
Introduce a function to detect a device's ability to upload files
Reported by: | johnbillion | Owned by: | azaozz |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | 3.4 |
Component: | Media | Keywords: | ux-feedback |
Focuses: | Cc: |
Description
Precursors: #20100 and #20405.
Some browser/OS combos don't allow files to be uploaded. The most common of these is Mobile Safari on iOS.
We should introduce a function which tells us if a given device is capable of uploading files. We can then use it in place of some of the wp_is_mobile()
calls (which were introduced in [20417] to replace the $is_iphone
global) where we need to hide certain UI elements relating to file uploads.
I propose a conditional function such as device_can_upload()
that defaults to a return value of true
but returns false
for known browser/OS/device combos that can't upload files. Browser sniffing is bad of course, but there's no other way to do it.
Attachments (4)
Change History (28)
#2
@
13 years ago
Yes, probably, but we'd have to make sure any corresponding error messages made sense instead of telling the user they don't have permission to upload files.
#3
@
13 years ago
- Component changed from General to Media
- Milestone changed from Awaiting Review to 3.4
- Version set to 3.4
Regression: since [20417], it's no longer possible to upload files using Opera Mini on Windows Mobile.
#4
@
13 years ago
- Keywords ux-feedback added
So in any case there should be a list of mobile devices + browsers combos that cannot upload files wrapped in a function similar to wp_is_mobile().
What would be a better UX here? Leaving the links to media-new.php, etc. visible everywhere and showing an error message that the device doesn't allow uploading or removing all links to media-new.php?
#5
follow-up:
↓ 6
@
13 years ago
20410.patch is the first attempt:
- Improves iPhone/iPad detection so that it doesn't catch other mobile Safari devices.
- Introduces
_device_can_upload()
and leverages it where appropriate. - Hooks in via
map_meta_cap()
forupload_files
.
However I've noticed that point 3 blocks access to Media Library, making it impossible to browse the files uploaded earlier.
20410.2.patch contains points 1 and 2.
#6
in reply to:
↑ 5
;
follow-up:
↓ 7
@
13 years ago
Replying to SergeyBiryukov:
- Improves iPhone/iPad detection so that it doesn't catch other mobile Safari devices.
Will these changes detect Mobile Safari on iPod?
#7
in reply to:
↑ 6
@
13 years ago
Replying to johnbillion:
Will these changes detect Mobile Safari on iPod?
I guess so. In 3.3, there was a similar check in _ipad_meta()
:
http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/misc.php#L588
However I've only tested with an emulator, would be great if anyone with a real device could confirm.
#8
follow-up:
↓ 9
@
13 years ago
Scratch that, I misread the question.
Seems we need to add a check for iPod as well.
#9
in reply to:
↑ 8
;
follow-up:
↓ 16
@
13 years ago
Replying to SergeyBiryukov:
Seems we need to add a check for iPod as well.
Seems we will need to add more devices there. For example Kindle Fire is Android based but no point in showing the file upload on it as there are no files that can be uploaded.
Thinking that in general we need to detect only mobile devices that have cameras (i.e. the device can create some sort of files) and allow browser access to the underlying OS so these files can be uploaded.
#10
@
13 years ago
Also: if we go with showing the upload screens everywhere but show an error message for devices that cannot upload, perhaps we can detect and handle that with JS. Seems would be better than to try to maintain a list of devices.
#11
@
13 years ago
I vote for showing the upload links and giving informative error messages so people don't just think the dashboard is broken. Informative = saying it is a device limitation.
#12
@
13 years ago
Proposed text for the error message:
"The web browser on your device cannot be used to upload files. If you need to upload images, for example photos you have taken with your smart phone or tablet, you may be able to use the native app for your device. There are <a href="http://wordpress.org/extend/mobile/">native WordPress apps</a> for all popular mobile platforms."
Or instead of "you may be able to use..." perhaps "please use...".
#13
@
13 years ago
Perhaps shorter?
"The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead."
#15
@
13 years ago
Missed the "props" on the above commit :(
Props go to SergeyBiryukov and helenyhou.
#16
in reply to:
↑ 9
;
follow-up:
↓ 17
@
13 years ago
Replying to azaozz:
Thinking that in general we need to detect only mobile devices that have cameras (i.e. the device can create some sort of files) and allow browser access to the underlying OS so these files can be uploaded.
That might be an inaccurate assumption. Some devices don't have a camera, but still can create text and sound files.
#17
in reply to:
↑ 16
@
13 years ago
Replying to SergeyBiryukov:
Yes, tested that on the Kindle Fire. It can upload files created there. Seems only iOS devices cannot upload.
#18
@
12 years ago
- Resolution set to fixed
- Status changed from new to closed
Seems to work properly. More devices can be added to _device_can_upload()
as needed.
#19
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
There's an odd space in the URL (20410.minor-typo-fix.patch).
#20
@
12 years ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from reopened to closed
In [20544]:
#21
follow-up:
↓ 22
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Type changed from enhancement to defect (bug)
This is complete bahloney, @ Wordcamp Atl today a gent introduced me to a plugin he wrote that opened the "take a photo/from library [sic] button options on his iphone 5. He has offered to write a plugin for me since this is a very simple feature he has included on the front end of many sites. I will add to this track any real code value I find in positive or negative within the month. I don't understand and why it's not already addressed.
#22
in reply to:
↑ 21
@
12 years ago
Replying to scamartist26:
I don't understand and why it's not already addressed.
You need to be using iOS 6 or newer. This was added in r21141 as per #20923.
For versions of iOS before iOS 6, Mobile Safari doesn't support uploads.
#23
@
12 years ago
- Resolution set to fixed
- Status changed from reopened to closed
- Type changed from defect (bug) to enhancement
Also, if you're not getting the correct behaviour, please open a new ticket.
Is this something we could reasonably hook in via map_meta_cap for upload_files?