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.
[ ] So inside json-api-response.js if we find we have no images multimedia on the main SPH record. Create and add a new "multimedia": [ element to the SPH record's main attributes and add the 1st multimedia record from each child to that element.
[ ] Also similarly update the thumbnail in search-results-to-template-data.js to be the first child record if no parent.
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.
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.
[ ] So inside json-api-response.js if we find we have no images
multimedia
on the main SPH record. Create and add a new"multimedia": [
element to the SPH record's main attributes and add the 1st multimedia record from each child to that element.[ ] Also similarly update the thumbnail in search-results-to-template-data.js to be the first child record if no parent.
ie. for each child record add the first element of the child's
multimedia
array to the parent's fakemultimedia
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.
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.