mysociety / fixmyblock-wordpress

1 stars 1 forks source link

Store image credits in attachment metadata, and automatically render at bottom of page #20

Closed zarino closed 4 years ago

zarino commented 4 years ago

I’ve noticed Myf is starting to add image credits to the ends of her pages:

Screen Shot 2020-04-15 at 13 09 11

Really this credit should be stored as metadata on the feature image itself, rather than as a paragraph at the end of the page content, because then:

  1. The credit only has to be defined once, and it’ll appear whenever the image is used.
  2. The right credit(s) will always be displayed automatically – no need to update credits when you add/remove/change the images attached to a post.

WordPress doesn’t have a built-in "credits" field in the attachment metadata. But:

We’ll then need some logic in the page templates to store the credits for any images rendered on the page, and print them all out in a single section at the end.