craftcms/guest-entries

How do you add alt text to an uploaded asset?

darylknight opened this issue · 0 comments

Given Craft's big push towards accessibility, hopefully this is already possible or could be implemented. We're working on a guest entries submission form where users submit two images, and each image has a description. These are currently saved as an asset field and a plain text field, but ideally it should attach the description to the asset's native alt field. Is that possible?

<div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mb-8">
	<div class="col-span-1">
		<label for="pupdateImage1" class="block mb-2">Image 1</label>
		<span class="text-gray mb-3 block">
			If you are uploading an image, you must provide a description
		</span>
		<div class="">
			<input type="file" id="pupdateImage1" name="fields[pupdateImage1][]" class="" />
		</div>
		{{ formSubmission ? _self.errorList(formSubmission.getErrors('pupdateImage1')) }}
	</div>
	<div class="col-span-1">
		<label for="fields[pupdateImage1Description]" class="block mb-2">Image 1 Description</label>
		<input type="text"
			name="fields[pupdateImage1Description]"
			id="fields[pupdateImage1Description]"
			class="w-full p-4 border-none" />
		{{ formSubmission ? _self.errorList(formSubmission.getErrors('pupdateImage1Description')) }}
	</div>
</div>