You can just add the subdirs to the array. I'm not really a coder, but I guess like so. {% set topic_images = { 120: { 3052: 'jbauck', 'subdir': 'ephemera' }, 121: { 3138: 'dbauer', 'subdir': 'someotherdir' }, } %} {% if topic_images[FORUM_ID][topicrow.TOPIC_ID] %} <img src="images/forumicons/s...