LTech
LTech

Reputation: 1761

upload image on mobile device for drupal site

I have a drupal site with the media module installed. When I click 'select media' and try to upload an image on a mobile device I get a blank box instead of the popup box with the upload option. I've checked the console and there are no error. How do I debug this and make it work on mobile.

Upvotes: 1

Views: 1046

Answers (1)

balintpekker
balintpekker

Reputation: 1844

You can add images to Drupal, but mobile devices don't allow you to upload any photos to image fields. (Android allows it as I remember.)

HTML5 allows this, but sadly that's mostly a no go with Drupal 7 at the moment. However, it turns out the fix is nice and easy via the HTML Media Capture method. Add the following snippet of jQuery, so it runs when pages load:

$('div.image-widget-data input[type="file"]').each(function(idx, item) {
   $(item).attr('accept', 'image/*;capture=camera');
});

That will look for items inside image widgets and add the accept attribute This then tells mobile devices they can upload image data and are allowed to grab that from their on-board camera.

To make that a spot simpler on Drupal, you can grab the Image Mobile Camera module from its sandbox on Drupal.org.

Now hit your blog via your tablet or phone (using a browser that supports this - Chrome is fine) and try it out.

Hope that helps

Upvotes: 1

Related Questions