I found a more adequate solution. According to the Tumblr documentation:
{block: IndexPage} {/ block: IndexPage} Displayed on index pages (post).
{block: PermalinkPage} {/ block: PermalinkPage} Displayed on pages with a constant position.
Thus, the code enclosed in the IndexPage block only runs on pages that can display more than one message, be it text, photo, video, etc.
... and the code enclosed in PermalinkPage will only work for pages with a constant position.
source share