Where you put the code does matter, but there's no easy answer to where it should be in the file as that would depend on your specific design.
Image files that are for your template, rather than the main content of your site (e.g. product images) should go in your "includes/templates/YOUR_TEMPLATE_FOLDER_NAME/images" folder.



