Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The input element should include camera as a possible argument for the capture attribute #11088

Closed
polaroidkidd opened this issue Apr 7, 2024 · 2 comments

Comments

@polaroidkidd
Copy link

polaroidkidd commented Apr 7, 2024

Describe the bug

I'm not quite sure why caniuse, mdn or w3 are not listing the camera argument as a possibility for an input field. I'm confused about caniuse because it specifically lists iOS 17.4 as not having support for this, but here I am, looking at my phone using this specific attribute to call up the camera. It also works on android/firefox.

is this even the right place to mention this?

Reproduction

I've implemented an example here. Just click the "browse" button on your mobile phone and it should open the camera directly. The relevant code is here or below.

I've had to do this ugly as "user" cast for in order to get TS to not complain about it.

<script lang="ts">
	const camera = 'camera' as 'user';
</script>

<label class=" mt-10 fileContainer ui-btn flex justify-center">
	<input
		class="mx-auto"
		type="file"
		accept="image/jpeg"
		id="photo_upload"
		multiple
		data-role="none"
		capture={camera}
	/>
</label>

You can check out the repo and remove the type cast, but you won't be able to run it locally since it lacks some tokens, but you'd get the gist from it.

is this even the right place to ask? Why are all the other parties not listing this?

Logs

No response

System Info

Tested on iOS 17.4.3, android 9 & FF 124.2.0.

Severity

annoyance

@Conduitry
Copy link
Member

What does capture=camera do that's different from capture=user or capture=environment? As far as I was reading on MDN user/environment let's you pick which camera to use.

@polaroidkidd
Copy link
Author

the capture attribute launches the camera directly on mobile devices. So instead of having the screen ask if you want to upload from files/gallery or take a picture, it'll launch the native camera app where you can snap a picture and then it'll load that into the input.

But, just as I was typing this out, I noticed that capture=user and capture=environment have the same effect. Closing this since it's a non-issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants