Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#20410 closed enhancement (fixed)

Introduce a function to detect a device's ability to upload files

Reported by: johnbillion's profile johnbillion Owned by: azaozz's profile 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)

20410.patch (5.2 KB) - added by SergeyBiryukov 12 years ago.
20410.2.patch (4.7 KB) - added by SergeyBiryukov 12 years ago.
20410.3.patch (4.7 KB) - added by SergeyBiryukov 12 years ago.
20410.minor-typo-fix.patch (747 bytes) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (28)

#1 @nacin
12 years ago

Is this something we could reasonably hook in via map_meta_cap for upload_files?

#2 @johnbillion
12 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 @SergeyBiryukov
12 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 @azaozz
12 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: @SergeyBiryukov
12 years ago

20410.patch is the first attempt:

  1. Improves iPhone/iPad detection so that it doesn't catch other mobile Safari devices.
  2. Introduces _device_can_upload() and leverages it where appropriate.
  3. Hooks in via map_meta_cap() for upload_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: @johnbillion
12 years ago

Replying to SergeyBiryukov:

  1. 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 @SergeyBiryukov
12 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.

Last edited 12 years ago by SergeyBiryukov (previous) (diff)

#8 follow-up: @SergeyBiryukov
12 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: @azaozz
12 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 @azaozz
12 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 @jane
12 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 @azaozz
12 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...".

Last edited 12 years ago by azaozz (previous) (diff)

#13 @helenyhou
12 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."

#14 @azaozz
12 years ago

In [20449]:

Don't hide links to the upload form and show an error for mobile devices that cannot upload, see #20410

#15 @azaozz
12 years ago

Missed the "props" on the above commit :(

Props go to SergeyBiryukov and helenyhou.

#16 in reply to: ↑ 9 ; follow-up: @SergeyBiryukov
12 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 @azaozz
12 years ago

Replying to SergeyBiryukov:

Yes, tested that on the Kindle Fire. It can upload files created there.

Version 0, edited 12 years ago by azaozz (next)

#18 @azaozz
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 @SergeyBiryukov
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 @azaozz
12 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from reopened to closed

In [20544]:

Fix typo in the error message shown when a device doesn't support uploading, props SergeyBiryukov, fixes #20410

#21 follow-up: @scamartist26
11 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 @rmccue
11 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 @rmccue
11 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.

#24 @scamartist26
11 years ago

Thanks! My version of of WP was behind. Sorry for the confusion.

Note: See TracTickets for help on using tickets.