Get post format

If you’re outside the loop, pass a post ID.

$format = get_post_format( $post_id );

To guard against missing formats, add a default to your template:

$format = get_post_format() ? : 'standard';

Then you can use your same IF statement:

if ( $format == 'link' ) :