I couldn’t find a solution to this so I modified the jetpack plugin to use the image alt-text (if it exists) instead of the image URL. There’s probably a more elegant solution but I was in a hurry and it works for my purposes.
The file that I changed: ../wp-content/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php
There are different functions for different gallery sizes (rectangular_talavera, square_talavera, etc) that all use the link, so I created a new function for the link logic:
private function get_link_url( $image ){
$alt_text = get_post_meta($image->ID, '_wp_attachment_image_alt', true);
if( $alt_text != ""){ // should probably check if it's a URL with regex...
return $alt_text;
}
$link = $this->get_attachment_link( $image->ID, $orig_file );
$search_text = "/project/";
$project_pos = strpos($link, $search_text);
if($project_pos !== FALSE){// this checks if the link is already a project and truncates the URL at the project itself instead of the project picture, since this is was the primary use case in my project
return substr($link, 0, strpos($link, "/", $project_pos + strlen($search_text)) + 1);
}
return $link;
}
This needs to be used in the two functions where the link is inserted. I found it in two places: rectangular_talavera and square_talavera, where I changed
$link = $this->get_attachment_link( $image->ID, $orig_file );
to
$link = $this->get_link_url($image);
which utilizes the new function above.
Voila, using the gallery image alt-text (or parent project) as the link instead of the image URL.