TheScienceMuseum / collectionsonline

Science Museum Group Collection Online
https://collection.sciencemuseumgroup.org.uk
MIT License
46 stars 3 forks source link

Pull 1st image assigned to each child record to top of page / carousel & thumbnail for SPH record #1528

Open jamieu opened 8 months ago

jamieu commented 8 months ago

Write code, but don't activate yet, we ideally want to enable/disable this functionality with a ENV variable/flag, so that we can check the different behaviour on live vs staging.


If there are no images for main SPH record then pull the first image off each child record and use those instead in main carousel.

With the first image acting as the thumbnail for the SPH record (in search results and other places)

On one hand the best place to do this is problay upstream, in json-to-html-data.js but as we also want to use the very first image as thumbnail and that thumbnail is used in lots of places form search results to the pages metadata tags and Twitter cards, I am wondering if we'd be better doing it at a much lower level in json-api-response.js so that no upstream code need to change.

ie. for each child record add the first element of the child's multimedia array to the parent's fake multimedia array.

NOTE: When adding the child images, additionally dd a 'fake' attribute to each child called "belongs_to_child": "677775" tat contains the UID of the child record the image belongs to. This will allow us and other SMG staff to understand when an image is really part of the SPH record and when it has been 'pulled up' form the child.

ie.

          "admin": {
            "id": "media-475896",
            "source": "smgi",
            "uid": "i475896",
            "uuid": "7075b26b-9e90-345a-a4e7-e12d70e1bacc"
          },
          **"belongs_to_child": "677775"**
          "credit": "Science Museum Group",
          "for_sale": "0",

That way not will appear to any existing code that the SPH record has some images.

This is a fuller snippet of the child multimedia record we want to 'pull up' (and add) to the parent new pseudo multimedia record.

        {
          "@link": {
            "type": "reference"
          },
          "admin": {
            "id": "media-475896",
            "source": "smgi",
            "uid": "i475896",
            "uuid": "7075b26b-9e90-345a-a4e7-e12d70e1bacc"
          },
          "credit": "Science Museum Group",
          "for_sale": "0",
          "identifier": [
            {
              "type": "iBase id",
              "value": "475896"
            }
          ],
          "priority": "0.5",
          "processed": {
            "large": {
              "format": "jpeg",
              "location": "https://coimages.sciencemuseumgroup.org.uk/images/475/896/large_SMG00244649.jpg",
              "measurements": {
                "dimensions": [
                  {
                    "dimension": "height",
                    "units": "pixels",
                    "value": 1026
                  },
                  {
                    "dimension": "width",
                    "units": "pixels",
                    "value": 1536
                  }
                ]
              },
evancp87 commented 2 weeks ago

@jamieu to talk to Adrian on this issue