You have apparently added a type value (I would make it the text 'Image' or 'Video', rather than a number) to the 'ALL' search result to identify which type each row is. I would make this same change to the 'Image' only and 'Video' only search code. You should also make the static/hard-coded content that's different between the repetitive sections in the template into replaceable parameters. This will let the php code supply all the dynamic content for each row being output.
You will then see that you only need ONE, simple, section in the template to handle any type of row in a search result, since each row of data supplies all the values needed.
The only conditional logic that would remain in the template is for anything that is actually different CONTENT, such as displaying the video length for type = video, that doesn't exist for images. If you have removed the video length, then your template should have NO conditional logic in it.
This will leave you with the simplest markup in the template, and assuming that the first section for 'Video' only works, you can use it as the final/remaining part to keep in the template.