some more images
This commit is contained in:
@@ -93,6 +93,11 @@ patchLandmarkImage(Landmark landmark) async {
|
||||
if (newUrl != null) {
|
||||
landmark.imageURL = newUrl;
|
||||
}
|
||||
} else if (landmark.imageURL!.contains("photos.app.goo.gl")) {
|
||||
// the image is a google photos link, we should get the image behind the link
|
||||
String? newUrl = await getImageUrlFromGooglePhotos(landmark.imageURL!);
|
||||
// also set the new url if it is null
|
||||
landmark.imageURL = newUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -58,3 +58,14 @@ Future<String?> getImageUrlFromName(String title) async {
|
||||
}
|
||||
return await getImageUrl(pageId);
|
||||
}
|
||||
|
||||
|
||||
Future<String?> getImageUrlFromGooglePhotos(String url) async {
|
||||
// this is a very simple implementation that just gets the image behind the link
|
||||
// it is not guaranteed to work for all google photos links
|
||||
final response = await dio.get(url);
|
||||
final data = response.toString();
|
||||
final int start = data.indexOf("https://lh3.googleusercontent.com");
|
||||
final int end = data.indexOf('"', start);
|
||||
return data.substring(start, end);
|
||||
}
|
||||
|
Reference in New Issue
Block a user