AtlasOfLivingAustralia / alerts

Alerts services
https://alerts.ala.org.au
Other
1 stars 6 forks source link

blog email template: add logic for retrieving thumbnail image URL #117

Open matthewandrews opened 3 years ago

matthewandrews commented 3 years ago

(ALA-specific issue, relating to the Blogs and News email template). There is no longer a direct URL to a featured image thumbnail in the JSON file parsed by the Blogs and News query (test example: https://www-test.ala.org.au/recentposts.json )

We now have, for each post, an element _links which contains an array wp:featuredmedia. We need the first item of wp:featuredmedia, which will have an element href. This will be a URL of the form https://www-test.ala.org.au/wp-json/wp/v2/media/43624 - note that this is NOT the URL of the image: this will return a JSON response.

In this media JSON, the media_details element contains a sizes element. This contains various elements for different image sizes: we want the thumbnail element. This contains three elements which would be useful to parse and make available to the blog template: file (URL of the actual thumbnail image), width (int), and height (int).

The alt_text element at the top level of the media JSON should also be made available.

The blog template will need to be modified to use these new values.

matthewandrews commented 3 years ago

Right now the media JSON is not available; this requires a change to the ALA home publish process (see https://github.com/AtlasOfLivingAustralia/ala-infrastructure/issues/814 ).

matthewandrews commented 3 years ago

Actually the process will be a bit different; the media_details / sizes element will probably become part of recentposts.json.

nickdos commented 3 years ago

@alexhuang091 this should be fairly quick to fix... if you're doing work on Alerts

qifeng-bai commented 7 months ago

The href links in ws:featureMedia link in https://www.ala.org.au/recentposts.json return 404