Developer forum

Forum » CMS - Standard features » Send 404 with alternative image

Send 404 with alternative image

Mafalda Correa
Mafalda Correa
Reply

Hi,

I've been testing the functionality of the 'Send 404 with alternative image' checkbox, to try and make it possible to report on missing images.

The objective is to be able to run an automatic tool to find all broken images in a website

This is needed for sites that have a large number of image files, whether they are product images, blog, events or content images.

Having thousands of images makes it impossible to keep track of all the images and therefore we need a way of reporting when the images are missing/have broken links. However, we don't want the site to show a broken image, we want to display the alternative image but still be able to be a 404 to build a report.

I ran some tests for the current functionality of the 'Send 404 with alternative image', passing the altFmImage_path parameter with the placeholder image and these are the results:

 

Send 404 header with alt image Image parameter Status Result=alt image URL
Yes Wrong path 404 No Link
Yes Empty 404 No Link
No Wrong path 200 Yes Link
No Empty 200 Yes Link

 

Basically, if we check 'Send 404 header with alternative image', we get the 404, but we do not get the alternative image. Considering the name is 404 header with alternative image, I believe the expected behaviour would be to get both.

 

The desired result would be to return alt image always but get 404 status to be aware that an image is missing/wrong.

Furthermore, to be able to do different reports on whether there's no image or if the path is wrong, we could also add an option to check for wrong images or wrong or empty images.

The proposal would be to have a radio button list instead of a checkbox, with the options: Nothing selected, Image path is wrong and Image path is wrong or empty.

 

Send 404 header with alt image when Image parameter Status Result=alt image
Nothing selected Empty 200 Yes
Nothing selected Wrong Path 200 Yes
Image path is wrong Empty 200 Yes
Image path is wrong Wrong Path 404 Yes
Image path is wrong or empty Empty 404 Yes
Image path is wrong or empty Wrong Path 404 Yes

Thank you

 


Replies

 
Nicolai Pedersen
Reply

Well, I think it is the limits of what we can with code. I think you need to find a way to configure this differently with web.config etc. 

BR Nicolai

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

I don't believe this is that complex (although I realize why you'd think that). Actually Imar and I did it with a previous image handler called ImageProcessor that we used prior to using GetImage again.

 

Essentially this is simply setting the response's StatusCode where it currently already is being set to 200

 

Essentially an image is always sent, but only the Status properties are tweaked based if GetImage is set to flag when the image path is empty or wrong.

 

Thoughts?

 

Best Regards,

Nuno Aguiar

 

You must be logged in to post in the forum