For this particular question (about images), there is also the issue of the URL for the image file. If the image is an external one (from some other website), that would make the URL easy to deal with, but would give your problem an external dependency, so it could break at any time. So we usually include the image files along with the .pg problem file. But the templates directory is not directly available to the web, so there are no URLs for the image files directly. Part of what the
image() function does in WeBWorK is make the image file available in a location that is available to the web. It also handles the image properly for inclusion in the LaTeX file that is used to create the hardcopy output.
So there is more to this than just creating some HTML to include an image.