return;
}
- if (!DBA::exists('contact', ['id' => $item['contact-id'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) {
+ $cdata = Contact::getPublicAndUserContactID($item['author-id'], $item['uid']);
+ if (empty($cdata['user']) || ($cdata['user'] != $item['contact-id'])) {
+ return;
+ }
+
+ if (!DBA::exists('contact', ['id' => $cdata['user'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) {
return;
}
];
Hook::callAll('prepare_body', $hook_data);
$s = $hook_data['html'];
-
+
unset($hook_data);
if (!$attach) {
*/
public static function makeImageGrid(array $images): string
{
- $landscapeimages = array();
- $portraitimages = array();
+ $landscapeimages = [];
+ $portraitimages = [];
foreach ($images as $image) {
($image['attachment']['width'] > $image['attachment']['height']) ? ($landscapeimages[] = $image) : ($portraitimages[] = $image);
}
// Image for first column (fc) and second column (sc)
- $images_fc = array();
- $images_sc = array();
- $lcount = count($landscapeimages);
- $pcount = count($portraitimages);
+ $images_fc = [];
+ $images_sc = [];
+ $lcount = count($landscapeimages);
+ $pcount = count($portraitimages);
if ($lcount == 0 || $pcount == 0) {
if ($lcount == 0) {
// only portrait
// Mix of landscape and portrait images.
if ($lcount == $pcount) {
// equal amount of landscapes and portraits
- for ($l = 0; $l < $lcount; $l++) {
- if ($l % 2 == 0) {
- $images_fc[] = $landscapeimages[$l];
- $images_fc[] = $portraitimages[$l];
- } else {
- $images_sc[] = $portraitimages[$l];
- $images_sc[] = $landscapeimages[$l];
+ if ($lcount == 1) {
+ // one left / one right
+ $images_fc[] = $landscapeimages[0];
+ $images_sc[] = $portraitimages[0];
+ } else {
+ // Distribute equal to both columns
+ for ($l = 0; $l < $lcount; $l++) {
+ if ($l % 2 == 0) {
+ // landscape left and portrait right for even numbers
+ $images_fc[] = $landscapeimages[$l];
+ $images_fc[] = $portraitimages[$l];
+ } else {
+ // portraits left and landscape right for odd numbers
+ $images_sc[] = $portraitimages[$l];
+ $images_sc[] = $landscapeimages[$l];
+ }
}
}
}
$media = '';
if (count($images) > 1) {
$media = self::makeImageGrid($images);
- }
- elseif (count($images) == 1) {
- $media = $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [
+ } elseif (count($images) == 1) {
+ $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [
'$image' => $images[0],
]);
}
}
if ($shared) {
- $content = str_replace(BBCode::TOP_ANCHOR, '<div class="body-attach">' . $leading . '<div class="clear"></div></div>' . BBCode::TOP_ANCHOR, $content);
- $content = str_replace(BBCode::BOTTOM_ANCHOR, '<div class="body-attach">' . $trailing . '<div class="clear"></div></div>' . BBCode::BOTTOM_ANCHOR, $content);
+ $content = str_replace(BBCode::TOP_ANCHOR, '<div class="body-attach">' . $leading . '</div>' . BBCode::TOP_ANCHOR, $content);
+ $content = str_replace(BBCode::BOTTOM_ANCHOR, '<div class="body-attach">' . $trailing . '</div>' . BBCode::BOTTOM_ANCHOR, $content);
} else {
if ($leading != '') {
- $content = '<div class="body-attach">' . $leading . '<div class="clear"></div></div>' . $content;
+ $content = '<div class="body-attach">' . $leading . '</div>' . $content;
}
if ($trailing != '') {
- $content .= '<div class="body-attach">' . $trailing . '<div class="clear"></div></div>';
+ $content .= '<div class="body-attach">' . $trailing . '</div>';
}
}
}
if ($trailing != '') {
- $content .= '<div class="body-attach">' . $trailing . '<div class="clear"></div></div>';
+ $content .= '<div class="body-attach">' . $trailing . '</div>';
}
DI::profiler()->stopRecording();