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

file uploads: alt text and multiple files #52

Closed
cweiske opened this issue Sep 19, 2016 · 2 comments
Closed

file uploads: alt text and multiple files #52

cweiske opened this issue Sep 19, 2016 · 2 comments

Comments

@cweiske
Copy link
Contributor

cweiske commented Sep 19, 2016

Files now may have an alt text:

Instead of the value being simply a URL, the value is instead an object with two properties: value being the URL and alt being the text.

which results in the following request parameters:

photo[value] = http://example.org/image.png
photo[alt] = example image

What happens if two images are uploaded?

Is it

photo[0][value] = http://example.org/image.png
photo[0][alt] = example image
photo[1][value] = http://example.org/image2.png
photo[1][alt] = example image2

or

photo[value][0] = http://example.org/image.png
photo[alt][0] = example image
photo[value][1] = http://example.org/image2.png
photo[alt][1] = example image2

?

@aaronpk
Copy link
Member

aaronpk commented Sep 19, 2016

The JSON format of two images with alt text is straightforward:

{
  "type": "h-entry",
  "properties": {
    "photo": [
      {
        "value": "http://example.com/photo1.jpg",
        "alt": "Photo 1"
      },
      {
        "value": "http://example.com/photo2.jpg",
        "alt": "Photo 2"
      }
    ]
  }
}

Converting that into a form-encoded request looks like:

type=h-entry&
properties[photo][0][value]=http://example.com/photo1.jpg&
properties[photo][0][alt]=Photo+1&
properties[photo][1][value]=http://example.com/photo2.jpg&
properties[photo][1][alt]=Photo+2

So the form-encoded Micropub version would be:

h=entry&
photo[0][value]=http://example.com/photo1.jpg&
photo[0][alt]=Photo+1&
photo[1][value]=http://example.com/photo2.jpg&
photo[1][alt]=Photo+2

This does point out that it becomes important to support the numeric array indexes in the form-encoded format. I will add a note that servers need to support both versions of array encoding photo[] and photo[0].

@aaronpk
Copy link
Member

aaronpk commented Sep 19, 2016

I've made some changes in a78366c, please close this issue if you feel this has clarified the situation. Thanks!

https://micropub.net/draft/#uploading-multiple-photos-with-alt-text

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

No branches or pull requests

2 participants