-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for terminal42/contao-pageimage #12
Comments
If so, it would be the other way around. Pageimage should support social images which should be pretty easy by setting |
Hm, I don't know, the current functionality of the If it's done the other way around, can the aforementioned order of images in the array be implemented? On the news reader page the image of the news teaser should be the first one in the array (i.e. the first one to be available for the facebook share dialogue for instance), rather than the page image of the news reader page. |
I think @Toflar is right here, it should go to the The order of images problem cannot be solved in an automated way I think. Perhaps there could be a page layout setting determining the order of images so you would be able to sort things manually. What do you think about that? |
Well, my reasoning was: The The However, I do get your point that other extensions can just freely push their images into the Regarding the order: I was wrong about the news teaser image currently always being first (when present), I'll probably open an issue for that (//edit: #13). In order to make it customizeable, maybe other extensions could (optionally) also push a priority number into the array. e.g. // content of $GLOBALS['SOCIAL_IMAGES'] after collecting images
$GLOBALS['SOCIAL_IMAGES'] = array
(
array
(
'priority' => 0,
'path' => 'files/some_content_element_image.jpg'
),
array
(
'priority' => 90,
'path' => 'files/social_image_from_page.jpg'
),
array
(
'priority' => 100,
'path' => 'files/some_news_teaser_image.jpg'
),
array
(
'priority' => 0,
'path' => 'files/some_content_element_image.jpg'
),
'some_image_from_another_extension_without_priority.jpg'
); Then process the array to be backwards compatible with elements in the array without priority and path: // processing the $GLOBALS['SOCIAL_IMAGES'] array
$GLOBALS['SOCIAL_IMAGES'] = array_map(function($element)
{
if (!is_array($element))
{
return array
(
'path' => $element,
'priority' => 50 // default priority
);
}
return $element;
},
$GLOBALS['SOCIAL_IMAGES']); Then sort the array according to the priority: // sorting the array (descending)
usort($GLOBALS['SOCIAL_IMAGES'], function($a,$b)
{
return $b['priority'] - $a['priority'];
}); Then extract the paths: // extracting the paths
$arrImages = array_unique(array_map(function($e){ return $e['path']; }, $GLOBALS['SOCIAL_IMAGES'])); But I think this is overkill. I think in most cases you simply want to have your news teaser image (when present) first and the social page image (when present) second and the order of the other images is arbitrary. |
I am closing this issue then as the main topic has been solved and the order images is being discussed in #13. |
I think it would be useful if the extension also supported taking the page image defined by the
pageimage
extension, when present. This image could be put in front of the other collected images, but after the news teaser image in the images array. So the order in the array would beThe text was updated successfully, but these errors were encountered: