Get Link value in Media entity
Try the following:

/**
 * Implements hook_preprocess_media().
 */
function mymodule_preprocess_media(&amp;$variables) {
  $media_entity = $variables['elements']['#media'];
  /**
   * @note: in case your field not multiple, otherwise loop through the field.
   */
  $link = $media_entity-&gt;get('field_link')-&gt;first();
  if ($link-&gt;isExternal()) {
    //- External.
    $link_value = $link-&gt;getValue()['uri'];
  }
  else {
    //- internal.
    $link_value = $link-&gt;getUrl()-&gt;toString();
  }
  $variables['custom_var'] = [
    'link_value' =&gt; $link_value,
  ];
}