You never check if `image_enable_href` is set (not None) so this will fail in case you don't set `image_enable_href` in the upper for loop.