Skip to content

Image API endpoint returns the fallback image when no size is specified #1453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Leptopoda opened this issue Jan 18, 2023 · 0 comments · Fixed by #2661
Closed

Image API endpoint returns the fallback image when no size is specified #1453

Leptopoda opened this issue Jan 18, 2023 · 0 comments · Fixed by #2661
Labels
bug Something isn't working

Comments

@Leptopoda
Copy link
Member

Leptopoda commented Jan 18, 2023

Description
As reported on matrix not specifying the size query param on the /api/v1/recipes/{id}/image endpoint will return the fallback fork and knife svg image.

Reproduction
Steps to reproduce the behavior:

  1. Go to https://cloud.domain.tld/apps/cookbook/webapp/recipes/10203181/image
  2. see the fork and knfe Icon
  3. bee mad that you suspected a bug in your code and spent too much in debugging xD

Expected behavior
As mentioned on matrix by @christianlupus:

The default (without parameter) should be the full image. If no image is present, the fallback should be presented.

Actual behavior
I get the fallback image

Screenshots
Cookbook expected
Cookbook bug

Browser
Firefox 108.0.2-arch

Versions
Nextcloud server version: Nextcloud Hub 3 (25.0.2)
Cookbook version: 0.10.1
Database system: MySQL

Notes*
My php is too rusty and I didn't find anything with a few quick searches but the size will default to null,

$size = isset($_GET['size']) ? $_GET['size'] : null;

and here it'll default to thumb:

public function getRecipeImageFileByFolderId($id, $size = 'thumb'): File {

In dart the default parameter of a function will only be used when not specified i.e. something like overloading.
This would mean as the footprint of the function called is getRecipeImageFileByFolderId(12345678, null) it won't even trigger the overloaded function.

The best thing would be to specify thumb as the default in the first place (or full as mentioned on matrix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant