Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/Service/RecipeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@
// If image data was fetched, write it to disk
if ($full_image_data) {
$this->imageService->setImageData($recipe_folder, $full_image_data);

// Replace external URL in JSON with the user-relative path to the local copy.
// Avoids leaking the source URL on edit and prevents re-downloading on the next
// save (the image_changed check on line above compares this field). The frontend
// renders `imageUrl` (an API route), not this field, so any stable non-URL value
// is safe.
if (isset($json['image']) && strpos($json['image'], 'http') === 0) {
$userFilesRoot = '/' . $this->user_id . '/files';
$json['image'] = substr($recipe_folder->getPath(), strlen($userFilesRoot)) . '/full.jpg';
$recipe_file->putContent(json_encode($json));
}
}

// Write .nomedia file to avoid gallery indexing
Expand Down Expand Up @@ -607,7 +618,7 @@

$recipe_folder = $recipe_folders[0];

// TODO: Check that file is really an image

Check warning on line 621 in lib/Service/RecipeService.php

View workflow job for this annotation

GitHub Actions / Check for added todo messages

Found TODO: Check that file is really an image
switch ($size) {
case 'full':
return $this->imageService->getImageAsFile($recipe_folder);
Expand Down
Loading