Hello! Due to the caching nature of CMSes in general you should prepare the image URL for every possible output in the template and hand it over via frontend measures, e.g. the browser or scripts.
If you’re handling images in content, you can use the <picture>
element and Javascript polyfill libraries.
If you’re using CSS rules, you can supply multiple images, including regular and retina assets and define them with media queries.