Skip to content
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

q=source on Media Endpoint #14

Open
dshanske opened this issue Mar 27, 2019 · 11 comments
Open

q=source on Media Endpoint #14

dshanske opened this issue Mar 27, 2019 · 11 comments
Labels
media endpoint Media Endpoint

Comments

@dshanske
Copy link
Member

Related #4

This is an implementation of the same feature proposed for the micropub endpoint, currently referenced on the Media Endpoint wiki page. https://indieweb.org/micropub_media_endpoint#Query_media_by_URL

The return would be an items property with the responses from #13

@manton
Copy link

manton commented Mar 25, 2020

I plan to support this in Micro.blog as soon as there's a recommendation for what the response looks like. I'd prefer to have as few required properties as possible… Maybe just file URL and date, and optionally width/height for images if available.

@manton
Copy link

manton commented May 23, 2020

@dshanske Does the WordPress plugin support this? I'm adding it to Micro.blog and the only thing I'm wondering about is the name for the date/time field. In #13 the example was date_time, but Micropub usually uses published.

@dshanske
Copy link
Member Author

Not yet, I documented these off the wiki.. published makes more sense as that is the proper mf property

@manton
Copy link

manton commented May 27, 2020

Thanks @dshanske. Here's what my response looks like in Micro.blog right now, from /micropub/media?q=source:

{
  "items": [
    {
      "url": "https://www.manton.org/uploads/2020/058fa92305.png", 
      "width": 1200, 
      "height": 816,
      "published": "2020-05-27T14:14:09+00:00"
    }, 
    {
      "url": "https://www.manton.org/uploads/2020/7a57980ca2.jpg", 
      "width": 1800, 
      "height": 1800,
      "published": "2020-05-20T02:22:09+00:00"
    }
  ]
}

It also supports limit and offset parameters.

@jalcine
Copy link

jalcine commented Jul 25, 2020

Going to look into implementing the response bit at https://git.jacky.wtf/indieweb/koype/issues/214

(Originally published at: https://v2.jacky.wtf/post/46bcf84e-7968-409b-b1a9-2c5f756331ff)

@dshanske
Copy link
Member Author

Agreement at the Micropub Pop-Up Session 2020 was to implement q=source with the response noted in #13. It would be subject to the proposed #35 and #36

@aaronpk
Copy link
Member

aaronpk commented Jul 26, 2020

My media endpoint now supports q=source and returns the latest 10 files uploaded.

{
  "items": [
    {
      "url": "https://media.aaronpk.com/2020/07/file-20200726XXX.jpg",
      "published": "2020-07-26T09:51:11-07:00",
      "mime_type": "image/jpeg"
    },
    {
      "url": "https://media.aaronpk.com/2020/07/file-20200726XXX.jpg",
      "published": "2020-07-26T08:49:24-07:00",
      "mime_type": "image/jpeg"
    }
  ]
}

The files are ordered newest first. It will only ever return a maximum of 10, but a client can request a limit using limit=1 to return up to 10 files.

@aaronpk
Copy link
Member

aaronpk commented Jul 26, 2020

Quill now queries the media endpoint to find the most recent uploaded file using ?q=source&limit=1. It expects to find a url, and if there is a published field then it will only display the photo if it was uploaded in the last 5 minutes.

@manton
Copy link

manton commented Jul 27, 2020

Micro.blog has been updated with support for limit and offset in the media endpoint. I've also simplified the response to only return url and published until there is a convention for other photo properties like dimensions, etc.

@paulrobertlloyd
Copy link

This query is supported by Indiekit.

It currently returns this object for a file:

{
  "basename": "3uv8j",
  "ext": "jpg",
  "filename": "3uv8j.jpg",
  "originalname": "photo.jpg",
  "content-type": "image/jpeg",
  "published": "2022-11-07T17:13:16.792Z",
  "post-type": "photo",
  "url": "https://getindiekit.github.io/sandbox/media/photos/2022/11/07/3uv8j.jpg"
}

This is a direct dump of properties from the database, but in retrospect, think I’ll remove some of those unneeded file name properties and simplify it to this:

{
  "content-type": "image/jpeg",
  "published": "2022-11-07T17:13:16.792Z",
  "post-type": "photo",
  "url": "https://getindiekit.github.io/sandbox/media/photos/2022/11/07/3uv8j.jpg"
}

@manton
Copy link

manton commented Mar 22, 2023

For videos in Micro.blog, we're adding a poster field for a still frame image from the video:

{
  "url": "…something.mov",
  "poster": "…something.png",
  "published": "…"
}

Still haven't added post type or dimensions because everyone seems to be handling that a little differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
media endpoint Media Endpoint
Projects
None yet
Development

No branches or pull requests

5 participants