moved media logic to template