Skip to content

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

Closed
@Leptopoda

Description

@Leptopoda

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions