Files
immich/mobile/lib/utils/image_url_builder.dart
T
Claude 2feee111fd feat(mobile): choose JPEG preview or original quality when sharing
Add a mechanism to share either the server-generated JPEG preview or the
full original file. When the selection contains at least one asset that can
provide a preview (a remote image), a bottom sheet lets the user pick the
quality; otherwise sharing falls back to the original as before.

The share-source resolution is extracted into pure, unit-tested business
logic that handles all three asset states (local, remote, merged):
- preview requires a remote image; videos and local-only assets fall back
  to the original
- original prefers the on-device file, but edited assets are downloaded
  since edits only exist on the server
- preview filenames are normalized to a .jpg extension

Add unit tests covering the resolution, gating and filename helpers.
2026-05-30 18:39:01 +00:00

30 lines
1.1 KiB
Dart

import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:openapi/api.dart';
String getOriginalUrlForRemoteId(final String id, {bool edited = true}) {
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/original?edited=$edited';
}
String getThumbnailUrlForRemoteId(
final String id, {
AssetMediaSize type = AssetMediaSize.thumbnail,
bool edited = true,
String? thumbhash,
}) {
final url = '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?size=${type.value}&edited=$edited';
return thumbhash != null ? '$url&c=${Uri.encodeComponent(thumbhash)}' : url;
}
String getPreviewUrlForRemoteId(final String id, {bool edited = true}) {
return getThumbnailUrlForRemoteId(id, type: AssetMediaSize.preview, edited: edited);
}
String getPlaybackUrlForRemoteId(final String id) {
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/video/playback?';
}
String getFaceThumbnailUrl(final String personId) {
return '${Store.get(StoreKey.serverEndpoint)}/people/$personId/thumbnail';
}