Fix errors related to missing vars

This plugin was still throwing error from undefined plugins, and the `$link` variable wasn't defined if there was an image. This tightens all that up.