Skip to content

mediaDetails sizes query returns incorrect value for "file" #2982

@philippahlfeld-netflow

Description

@philippahlfeld-netflow

Description

Query to get mediaDetails size URL on any image returns a wrong file attribute. Return value is missing year/month segment and hence returns 404 when requested. The sourceUrl for however returns the corrects absolute url.

Steps to reproduce

Add New Post, set Featured image:

Query:

{
  post(id: "sample-post", idType: SLUG) {
    featuredImage {
      node {
        mediaDetails {
          sizes(include: THUMBNAIL) {
            file
            height
            width
          }
          height
          file
          width
        }
      }
    }
  }
}

Additional context

Output:

{
  "data": {
    "post": {
      "featuredImage": {
        "node": {
          "mediaDetails": {
            "sizes": [
              {
                "file": "sample-image-150x150.png",
                "height": "150",
                "width": "150",
                "sourceUrl": "https://sample.site/app/uploads/2023/11/sample-image-150x150.png"
              }
            ],
            "height": 797,
            "file": "2023/11/sample-image.png",
            "width": 1015
          }
        }
      }
    }
  },
  "extensions": {
    "debug": [],
    "graphqlSmartCache": {
      "graphqlObjectCache": []
    },
    "queryAnalyzer": {
      "keys": "7bce018bada4536cc202d7f1fcd3b8214c967eaa42e8afcd6c3be86cc4941c40 graphql:Query cG9zdDoxMDA1 cG9zdDoxMDA2",
      "keysLength": 104,
      "keysCount": 4,
      "skippedKeys": "",
      "skippedKeysSize": 0,
      "skippedKeysCount": 0,
      "skippedTypes": []
    }
  }
}

WPGraphQL Version

1.18.0

WordPress Version

6.3.2

PHP Version

8.1.18

Additional environment details

Using roots/sage ontop of bedrock for WP, which is the reason for the /app/ fragment in the returned URL: https://roots.io/

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: reproductionThis issue needs to be reproduced independentlytype: bugIssue that causes incorrect or unexpected behavior

    Type

    No fields configured for Bug.

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions