I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
There are services like Unsplash which are great for images, they even request that you hotlink from their CDN and it comes with some neat options like resolution and compression.
When you search for an image using Google you can click the Tools button and use the Usage Rights menu to filter the images by license. It is not 100% foolproof but it is better than nothing.
Otherwise, you have to check the license the image was released under and make sure you are allowed to use it, which might be a bit hard at times.
When hotlinking you have to check the site TOS if it has any. In general, hotlinking images is considered poor netiquette. Some sites block hotlinking images or block some hosts from using hot-linked images.
For the challenge projects, it really isn’t that big of a deal as you are not going to have thousands of people loading the page. If it is for a professional project you absolutely must make sure you are not in any license violation and don’t use hotlinking but host the image or use a CDN or a service like Unsplash.