making the directive generic, can be nested(relying on document.images api now)