WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#39640 closed enhancement (invalid)

Link href identifier for images inserted from gallery

Reported by: Kubbik Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: REST API Keywords:
Focuses: rest-api Cc:
PR Number:

Description

I creating the application, and communicate with REST API. I need href link identifier, inserted from Media, such as a Media File, Attachment Page, Custom URL. I need to identify what type of link is. It is possible to add to the REST API, when generating href posts with tags?

Clarify image:
https://pixady.com/img/2017/01/237519_screenshot.png

Change History (3)

This ticket was mentioned in Slack in #core-restapi by kadamwhite. View the logs.


3 years ago

#2 @kadamwhite
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

@Kubbik Thank you for using the REST API, and for your question! The dropdown you are referencing is part of the media UI, not specifically a part of the REST API itself; the value comes from a user UI preferences object that is specific to the WordPress Admin and not related to the REST API. To explain, for any media item, you may insert it into the post using either

  • its original media file (the .source_url property of the media record as returned from the API);
  • its attachment page (the .link property of a media record);
  • a completely custom URL, or
  • no wrapping link object.

The value you select is not stored as part of the media object, so it would not make sense to return it in the response from the media endpoint within the REST API. It is up to the UI of your application to provide this sort of interface when inserting an image. Once inserted, it is possible to infer what option a user selected by comparing the href value to the .link or .source_url properties; if it matches one of those it is a link to the media file or attachment page, otherwise it is a custom link (or not present at all).

I am going to close this issue as it does not reflect a defect of the REST API. Thanks again, and if you have further questions, please let us know in the support forums at https://wordpress.org/support/

#3 @jnylen0
3 years ago

If this information were to be included in the REST API, it would be much, much later, as part of the final stages of the block-based editor project: https://make.wordpress.org/core/2017/01/17/editor-technical-overview/

There could be an API endpoint that returns the list of blocks associated with a post's content, and this "link type" could be a property of the block information for an "attachment" block that has been inserted into the post.

Note: See TracTickets for help on using tickets.