Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

osama_abdullah's avatar

Default image field is downloading the image with wrong extension when the image is from storage

// #image
OrderImage::make('Image')
	->url('/orders/order/' . optional($this)->image . '/get-preview-image')
	->canSee(function () use ($user) {
		return $user->hasPermission('orders-fields-image-see');
	})
	->hideWhenUpdating(! $user->hasPermission('orders-fields-image-edit'))
	->disk('orderImages')
	->prunable($isNotDefault = optional($this)->image !== 'default.png')
	->deletable(false)
	->acceptedTypes('image/*')
	->rules('required', 'mimes:jpg,jpeg,bmp,png,webp', 'max:3000')

this is the code responsible for displaing the image in view page of the resource and there is a default download link that filed offers provide out of the box, when i press that link or try to save the image it will be saved by (.htm) extention but if u manully change the extention to .png or .jpeg it works fine

how to download it with its original extension as usual?

knowing that I have tried to implement

	->download(function () {
					
	})

countless times returning all possible things

0 likes
5 replies
bobbybouwmann's avatar

I'm not sure what you mean with the download URL? Can you show what is outputted in HTML and how you create it?

Also OrderImage is not a default field in Laravel Nova. Can you tell us which package you use? Or is this your own implementation?

1 like
osama_abdullah's avatar

@bobbybouwmann

OrderImage extends Image the same it's my implementation

in view page, the default image field displays an image in a box under the box there is a clickable text (download) normally when you click that it will download the image in my case it's also downloading the image but the extension of the downloaded image is wrong its (.htm) instead of (.png, .jpeg ...etc) so the downloaded images won't be an image unless you change back the extension to what it was b4, I have tried al almost all related to download methods on image filed but no one seems to be working

osama_abdullah's avatar

@bobbybouwmann I don't nova is doing that out of the box, the code I showed above is the only code that responsible for that field

also, I tried this nothing chaged

->download(function () use ($user) {
	return url('/orders/order/' . $this->image . '/get-preview-image');
})
bobbybouwmann's avatar

The problem is this ->url('/orders/order/' . optional($this)->image . '/get-preview-image'). That URL doesn't have the image extension so it doesn't understand it. That is my best bet.

Please or to participate in this conversation.