3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 use Friendica\Content\Nav;
24 use Friendica\Content\Pager;
25 use Friendica\Content\Text\BBCode;
26 use Friendica\Content\Widget;
27 use Friendica\Core\ACL;
28 use Friendica\Core\Addon;
29 use Friendica\Core\Hook;
30 use Friendica\Core\Logger;
31 use Friendica\Core\Renderer;
32 use Friendica\Core\System;
33 use Friendica\Database\DBA;
34 use Friendica\Database\DBStructure;
36 use Friendica\Model\Contact;
37 use Friendica\Model\Item;
38 use Friendica\Model\Photo;
39 use Friendica\Model\Post;
40 use Friendica\Model\Profile;
41 use Friendica\Model\Tag;
42 use Friendica\Model\User;
43 use Friendica\Module\BaseProfile;
44 use Friendica\Network\HTTPException;
45 use Friendica\Network\Probe;
46 use Friendica\Protocol\Activity;
47 use Friendica\Security\Security;
48 use Friendica\Util\Crypto;
49 use Friendica\Util\DateTimeFormat;
50 use Friendica\Util\Images;
51 use Friendica\Util\Map;
52 use Friendica\Util\Strings;
53 use Friendica\Util\Temporal;
54 use Friendica\Util\XML;
56 function photos_init(App $a)
58 if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
62 Nav::setSelected('home');
64 if (DI::args()->getArgc() > 1) {
65 $owner = Profile::load(DI::app(), DI::args()->getArgv()[1], false);
66 if (!isset($owner['account_removed']) || $owner['account_removed']) {
67 throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
70 $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner['uid']));
72 $albums = Photo::getAlbums($owner['uid']);
74 $albums_visible = ((intval($owner['hidewall']) && !DI::userSession()->isAuthenticated()) ? false : true);
76 // add various encodings to the array so we can just loop through and pick them out in a template
77 $ret = ['success' => false];
80 if ($albums_visible) {
81 $ret['success'] = true;
85 foreach ($albums as $k => $album) {
87 'text' => $album['album'],
88 'total' => $album['total'],
89 'url' => 'photos/' . $owner['nickname'] . '/album/' . bin2hex($album['album']),
90 'urlencode' => urlencode($album['album']),
91 'bin2hex' => bin2hex($album['album'])
93 $ret['albums'][] = $entry;
97 if (DI::userSession()->getLocalUserId() && $owner['uid'] == DI::userSession()->getLocalUserId()) {
103 if ($ret['success']) {
104 $photo_albums_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('photo_albums.tpl'), [
105 '$nick' => $owner['nickname'],
106 '$title' => DI::l10n()->t('Photo Albums'),
107 '$recent' => DI::l10n()->t('Recent Photos'),
108 '$albums' => $ret['albums'],
109 '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $owner['nickname'] . '/upload'],
110 '$can_post' => $can_post
114 if (!empty($photo_albums_widget)) {
115 DI::page()['aside'] .= $photo_albums_widget;
118 $tpl = Renderer::getMarkupTemplate("photos_head.tpl");
120 DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl,[
121 '$ispublic' => DI::l10n()->t('everybody')
128 function photos_post(App $a)
130 $user = User::getByNickname(DI::args()->getArgv()[1]);
131 if (!DBA::isResult($user)) {
132 throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
135 $phototypes = Images::supportedTypes();
140 $page_owner_uid = intval($user['uid']);
141 $community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
143 if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $page_owner_uid)) {
145 } elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
146 $contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
148 $visitor = $contact_id;
152 DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
156 $owner_record = User::getOwnerDataById($page_owner_uid);
158 if (!$owner_record) {
159 DI::sysmsg()->addNotice(DI::l10n()->t('Contact information unavailable'));
160 DI::logger()->info('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
164 $aclFormatter = DI::aclFormatter();
165 $str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
166 $str_group_allow = isset($_REQUEST['group_allow']) ? $aclFormatter->toString($_REQUEST['group_allow']) : $owner_record['allow_gid'] ?? '';
167 $str_contact_deny = isset($_REQUEST['contact_deny']) ? $aclFormatter->toString($_REQUEST['contact_deny']) : $owner_record['deny_cid'] ?? '';
168 $str_group_deny = isset($_REQUEST['group_deny']) ? $aclFormatter->toString($_REQUEST['group_deny']) : $owner_record['deny_gid'] ?? '';
170 $visibility = $_REQUEST['visibility'] ?? '';
171 if ($visibility === 'public') {
172 // The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
173 $str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
174 } else if ($visibility === 'custom') {
175 // Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
176 // case that would make it public. So we always append the author's contact id to the allowed contacts.
177 // See https://github.com/friendica/friendica/issues/9672
178 $str_contact_allow .= $aclFormatter->toString(Contact::getPublicIdByUserId($page_owner_uid));
181 if (DI::args()->getArgc() > 3 && DI::args()->getArgv()[2] === 'album') {
182 if (!Strings::isHex(DI::args()->getArgv()[3] ?? '')) {
183 DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
185 $album = hex2bin(DI::args()->getArgv()[3]);
187 if (!DBA::exists('photo', ['album' => $album, 'uid' => $page_owner_uid, 'photo-type' => Photo::DEFAULT])) {
188 DI::sysmsg()->addNotice(DI::l10n()->t('Album not found.'));
189 DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
190 return; // NOTREACHED
193 // Check if the user has responded to a delete confirmation query
194 if (!empty($_REQUEST['canceled'])) {
195 DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album/' . DI::args()->getArgv()[3]);
198 // RENAME photo album
199 $newalbum = trim($_POST['albumname'] ?? '');
200 if ($newalbum != $album) {
201 Photo::update(['album' => $newalbum], ['album' => $album, 'uid' => $page_owner_uid]);
202 // Update the photo albums cache
203 Photo::clearAlbumCache($page_owner_uid);
205 DI::baseUrl()->redirect('photos/' . $a->getLoggedInUserNickname() . '/album/' . bin2hex($newalbum));
206 return; // NOTREACHED
210 * DELETE all photos filed in a given album
212 if (!empty($_POST['dropalbum'])) {
215 // get the list of photos we are about to delete
217 $r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = ? AND `uid` = ? AND `album` = ?",
223 $r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
224 DI::userSession()->getLocalUserId(),
229 if (DBA::isResult($r)) {
230 foreach ($r as $rr) {
234 // remove the associated photos
235 Photo::delete(['resource-id' => $res, 'uid' => $page_owner_uid]);
237 // find and delete the corresponding item with all the comments and likes/dislikes
238 Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
240 // Update the photo albums cache
241 Photo::clearAlbumCache($page_owner_uid);
242 DI::sysmsg()->addNotice(DI::l10n()->t('Album successfully deleted'));
244 DI::sysmsg()->addNotice(DI::l10n()->t('Album was empty.'));
248 DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
251 if (DI::args()->getArgc() > 3 && DI::args()->getArgv()[2] === 'image') {
252 // Check if the user has responded to a delete confirmation query for a single photo
253 if (!empty($_POST['canceled'])) {
254 DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]);
257 if (!empty($_POST['delete'])) {
258 // same as above but remove single photo
260 $condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
263 $condition = ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => DI::args()->getArgv()[3]];
266 $photo = DBA::selectFirst('photo', ['resource-id'], $condition);
268 if (DBA::isResult($photo)) {
269 Photo::delete(['uid' => $page_owner_uid, 'resource-id' => $photo['resource-id']]);
271 Item::deleteForUser(['resource-id' => $photo['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
273 // Update the photo albums cache
274 Photo::clearAlbumCache($page_owner_uid);
276 DI::sysmsg()->addNotice(DI::l10n()->t('Failed to delete the photo.'));
277 DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]);
280 DI::baseUrl()->redirect('profile/' . DI::args()->getArgv()[1] . '/photos');
284 if (DI::args()->getArgc() > 2 && (!empty($_POST['desc']) || !empty($_POST['newtag']) || isset($_POST['albname']))) {
285 $desc = !empty($_POST['desc']) ? trim($_POST['desc']) : '';
286 $rawtags = !empty($_POST['newtag']) ? trim($_POST['newtag']) : '';
287 $item_id = !empty($_POST['item_id']) ? intval($_POST['item_id']) : 0;
288 $albname = !empty($_POST['albname']) ? trim($_POST['albname']) : '';
289 $origaname = !empty($_POST['origaname']) ? trim($_POST['origaname']) : '';
291 $resource_id = DI::args()->getArgv()[3];
293 if (!strlen($albname)) {
294 $albname = DateTimeFormat::localNow('Y');
297 if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) {
298 Logger::debug('rotate');
300 $photo = Photo::getPhotoForUser($page_owner_uid, $resource_id);
302 if (DBA::isResult($photo)) {
303 $image = Photo::getImageForPhoto($photo);
305 if ($image->isValid()) {
306 $rotate_deg = ((intval($_POST['rotate']) == 1) ? 270 : 90);
307 $image->rotate($rotate_deg);
309 $width = $image->getWidth();
310 $height = $image->getHeight();
312 Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 0], $image);
314 if ($width > 640 || $height > 640) {
315 $image->scaleDown(640);
316 $width = $image->getWidth();
317 $height = $image->getHeight();
319 Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 1], $image);
322 if ($width > 320 || $height > 320) {
323 $image->scaleDown(320);
324 $width = $image->getWidth();
325 $height = $image->getHeight();
327 Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 2], $image);
333 $photos_stmt = DBA::select('photo', [], ['resource-id' => $resource_id, 'uid' => $page_owner_uid], ['order' => ['scale' => true]]);
335 $photos = DBA::toArray($photos_stmt);
337 if (DBA::isResult($photos)) {
339 $ext = $phototypes[$photo['type']];
341 ['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny],
342 ['resource-id' => $resource_id, 'uid' => $page_owner_uid]
345 // Update the photo albums cache if album name was changed
346 if ($albname !== $origaname) {
347 Photo::clearAlbumCache($page_owner_uid);
351 if (DBA::isResult($photos) && !$item_id) {
352 // Create item container
354 $uri = Item::newURI();
357 $arr['guid'] = System::createUUID();
358 $arr['uid'] = $page_owner_uid;
360 $arr['post-type'] = Item::PT_IMAGE;
362 $arr['resource-id'] = $photo['resource-id'];
363 $arr['contact-id'] = $owner_record['id'];
364 $arr['owner-name'] = $owner_record['name'];
365 $arr['owner-link'] = $owner_record['url'];
366 $arr['owner-avatar'] = $owner_record['thumb'];
367 $arr['author-name'] = $owner_record['name'];
368 $arr['author-link'] = $owner_record['url'];
369 $arr['author-avatar'] = $owner_record['thumb'];
370 $arr['title'] = $title;
371 $arr['allow_cid'] = $photo['allow_cid'];
372 $arr['allow_gid'] = $photo['allow_gid'];
373 $arr['deny_cid'] = $photo['deny_cid'];
374 $arr['deny_gid'] = $photo['deny_gid'];
378 $arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $photo['resource-id'] . ']'
379 . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $photo['scale'] . '.'. $ext . '[/img]'
382 $item_id = Item::insert($arr);
386 $item = Post::selectFirst(['inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]);
388 if (DBA::isResult($item)) {
389 $old_inform = $item['inform'];
393 if (strlen($rawtags)) {
396 // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
397 $x = substr($rawtags, 0, 1);
398 if ($x !== '@' && $x !== '#') {
399 $rawtags = '#' . $rawtags;
403 $tags = BBCode::getTags($rawtags);
406 foreach ($tags as $tag) {
407 if (strpos($tag, '@') === 0) {
410 $name = substr($tag,1);
412 if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
414 $links = @Probe::lrdd($name);
417 foreach ($links as $link) {
418 if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
419 $profile = $link['@attributes']['href'];
422 if ($link['@attributes']['rel'] === 'salmon') {
423 $salmon = '$url:' . str_replace(',', '%sc', $link['@attributes']['href']);
425 if (strlen($inform)) {
434 $taginfo[] = [$newname, $profile, $salmon];
439 if (strrpos($newname, '+')) {
440 $tagcid = intval(substr($newname, strrpos($newname, '+') + 1));
444 $contact = DBA::selectFirst('contact', [], ['id' => $tagcid, 'uid' => $page_owner_uid]);
446 $newname = str_replace('_',' ',$name);
448 //select someone from this user's contacts by name
449 $contact = DBA::selectFirst('contact', [], ['name' => $newname, 'uid' => $page_owner_uid]);
450 if (!DBA::isResult($contact)) {
451 //select someone by attag or nick and the name passed in
452 $contact = DBA::selectFirst('contact', [],
453 ['(`attag` = ? OR `nick` = ?) AND `uid` = ?', $name, $name, $page_owner_uid],
454 ['order' => ['attag' => true]]
459 if (DBA::isResult($contact)) {
460 $newname = $contact['name'];
461 $profile = $contact['url'];
463 $notify = 'cid:' . $contact['id'];
464 if (strlen($inform)) {
472 if (!empty($contact)) {
473 $taginfo[] = [$newname, $profile, $notify, $contact];
475 $taginfo[] = [$newname, $profile, $notify, null];
478 $profile = str_replace(',', '%2c', $profile);
480 if (!empty($item['uri-id'])) {
481 Tag::store($item['uri-id'], Tag::MENTION, $newname, $profile);
484 } elseif (strpos($tag, '#') === 0) {
485 $tagname = substr($tag, 1);
486 if (!empty($item['uri-id'])) {
487 Tag::store($item['uri-id'], Tag::HASHTAG, $tagname);
493 $newinform = $old_inform ?? '';
494 if (strlen($newinform) && strlen($inform)) {
497 $newinform .= $inform;
499 $fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
500 $condition = ['id' => $item_id];
501 Item::update($fields, $condition);
504 foreach ($photos as $scales) {
505 if (intval($scales['scale']) == 2) {
510 if (intval($scales['scale']) == 4) {
516 if (count($taginfo)) {
517 foreach ($taginfo as $tagged) {
518 $uri = Item::newURI();
521 'guid' => System::createUUID(),
522 'uid' => $page_owner_uid,
525 'contact-id' => $owner_record['id'],
526 'owner-name' => $owner_record['name'],
527 'owner-link' => $owner_record['url'],
528 'owner-avatar' => $owner_record['thumb'],
529 'author-name' => $owner_record['name'],
530 'author-link' => $owner_record['url'],
531 'author-avatar' => $owner_record['thumb'],
533 'allow_cid' => $photo['allow_cid'],
534 'allow_gid' => $photo['allow_gid'],
535 'deny_cid' => $photo['deny_cid'],
536 'deny_gid' => $photo['deny_gid'],
538 'verb' => Activity::TAG,
539 'gravity' => Item::GRAVITY_PARENT,
540 'object-type' => Activity\ObjectType::PERSON,
541 'target-type' => Activity\ObjectType::IMAGE,
542 'inform' => $tagged[2],
544 'body' => DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') . "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n",
545 'object' => '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n"),
546 'target' => '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>',
550 $arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
552 $arr['object'] .= '</link></object>' . "\n";
558 DI::baseUrl()->redirect($_SESSION['photo_return']);
559 return; // NOTREACHED
563 function photos_content(App $a)
566 // photos/name/upload
567 // photos/name/upload/xxxxx (xxxxx is album name)
568 // photos/name/album/xxxxx
569 // photos/name/album/xxxxx/edit
570 // photos/name/album/xxxxx/drop
571 // photos/name/image/xxxxx
572 // photos/name/image/xxxxx/edit
573 // photos/name/image/xxxxx/drop
575 $user = User::getByNickname(DI::args()->getArgv()[1] ?? '');
576 if (!DBA::isResult($user)) {
577 throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
580 if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
581 DI::sysmsg()->addNotice(DI::l10n()->t('Public access denied.'));
586 DI::sysmsg()->addNotice(DI::l10n()->t('No photos selected'));
590 $profile = Profile::getByUID($user['uid']);
592 $phototypes = Images::supportedTypes();
594 $_SESSION['photo_return'] = DI::args()->getCommand();
598 if (DI::args()->getArgc() > 3) {
599 $datatype = DI::args()->getArgv()[2];
600 $datum = DI::args()->getArgv()[3];
601 } elseif ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[2] === 'upload')) {
602 $datatype = 'upload';
604 $datatype = 'summary';
607 if (DI::args()->getArgc() > 4) {
608 $cmd = DI::args()->getArgv()[4];
613 // Setup permissions structures
617 $remote_contact = false;
622 $owner_uid = $user['uid'];
624 $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
626 if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid)) {
628 } elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
629 $contact_id = DI::userSession()->getRemoteContactID($owner_uid);
630 $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
632 if (DBA::isResult($contact)) {
634 $remote_contact = true;
635 $visitor = $contact_id;
639 // perhaps they're visiting - but not a community page, so they wouldn't have write access
640 if (!empty(DI::userSession()->getRemoteContactID($owner_uid)) && !$visitor) {
641 $contact_id = DI::userSession()->getRemoteContactID($owner_uid);
643 $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
645 $remote_contact = DBA::isResult($contact);
648 if (!$remote_contact && DI::userSession()->getLocalUserId()) {
649 $contact_id = $_SESSION['cid'];
651 $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
654 if ($user['hidewall'] && !DI::userSession()->isAuthenticated()) {
655 DI::baseUrl()->redirect('profile/' . $user['nickname'] . '/restricted');
658 $sql_extra = Security::getPermissionsSQLByUserId($owner_uid);
663 $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid));
664 $o .= BaseProfile::getTabsHTML('photos', $is_owner, $user['nickname'], $profile['hide-friends']);
666 // Display upload form
667 if ($datatype === 'upload') {
669 DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
673 // This prevents the photo upload form to return to itself without a hint the picture has been correctly uploaded.
674 DI::session()->remove('photo_return');
676 $selname = (!is_null($datum) && Strings::isHex($datum)) ? hex2bin($datum) : '';
680 $albumselect .= '<option value="" ' . (!$selname ? ' selected="selected" ' : '') . '><current year></option>';
681 $albums = Photo::getAlbums($owner_uid);
682 if (!empty($albums)) {
683 foreach ($albums as $album) {
684 if ($album['album'] === '') {
687 $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
688 $albumselect .= '<option value="' . $album['album'] . '"' . $selected . '>' . $album['album'] . '</option>';
694 $ret = ['post_url' => 'profile/' . $user['nickname'] . '/photos',
695 'addon_text' => $uploader,
696 'default_upload' => true];
698 Hook::callAll('photo_upload_form',$ret);
700 $default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
701 $default_upload_submit = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_submit.tpl'), [
702 '$submit' => DI::l10n()->t('Submit'),
705 // Get the relevant size limits for uploads. Abbreviated var names: MaxImageSize -> mis; upload_max_filesize -> umf
706 $mis_bytes = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
707 $umf_bytes = Strings::getBytesFromShorthand(ini_get('upload_max_filesize'));
709 // Per Friendica definition a value of '0' means unlimited:
710 If ($mis_bytes == 0) {
714 // When PHP is configured with upload_max_filesize less than maximagesize provide this lower limit.
715 $maximagesize_bytes = (is_numeric($mis_bytes) && ($mis_bytes < $umf_bytes) ? $mis_bytes : $umf_bytes);
717 // @todo We may be want to use appropriate binary prefixed dynamically
718 $usage_message = DI::l10n()->t('The maximum accepted image size is %s', Strings::formatBytes($maximagesize_bytes));
720 $tpl = Renderer::getMarkupTemplate('photos_upload.tpl');
722 $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()));
724 $o .= Renderer::replaceMacros($tpl,[
725 '$pagename' => DI::l10n()->t('Upload Photos'),
726 '$sessid' => session_id(),
727 '$usage' => $usage_message,
728 '$nickname' => $user['nickname'],
729 '$newalbum' => DI::l10n()->t('New album name: '),
730 '$existalbumtext' => DI::l10n()->t('or select existing album:'),
731 '$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
732 '$albumselect' => $albumselect,
733 '$permissions' => DI::l10n()->t('Permissions'),
734 '$aclselect' => $aclselect_e,
735 '$lockstate' => ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock',
736 '$alt_uploader' => $ret['addon_text'],
737 '$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
738 '$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''),
739 '$uploadurl' => $ret['post_url'],
741 // ACL permissions box
742 '$return_path' => DI::args()->getQueryString(),
748 // Display a single photo album
749 if ($datatype === 'album') {
750 // if $datum is not a valid hex, redirect to the default page
751 if (is_null($datum) || !Strings::isHex($datum)) {
752 DI::baseUrl()->redirect('photos/' . $user['nickname']. '/album');
754 $album = hex2bin($datum);
756 if ($can_post && !Photo::exists(['uid' => $owner_uid, 'album' => $album, 'photo-type' => Photo::DEFAULT])) {
761 $r = DBA::toArray(DBA::p("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `album` = ?
762 AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
766 if (DBA::isResult($r)) {
770 $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 20);
772 /// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
773 $order_field = $_GET['order'] ?? '';
774 if ($order_field === 'created') {
780 $r = DBA::toArray(DBA::p("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
781 ANY_VALUE(`type`) AS `type`, max(`scale`) AS `scale`, ANY_VALUE(`desc`) as `desc`,
782 ANY_VALUE(`created`) as `created`
783 FROM `photo` WHERE `uid` = ? AND `album` = ?
784 AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` $order LIMIT ? , ?",
788 $pager->getItemsPerPage()
791 if ($cmd === 'drop') {
792 $drop_url = DI::args()->getQueryString();
794 return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
796 'message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
797 'confirm' => DI::l10n()->t('Delete Album'),
798 'cancel' => DI::l10n()->t('Cancel'),
801 '$confirm_url' => $drop_url,
802 '$confirm_name' => 'dropalbum',
803 '$confirm_value' => 'dropalbum',
808 if ($cmd === 'edit') {
810 $edit_tpl = Renderer::getMarkupTemplate('album_edit.tpl');
814 $o .= Renderer::replaceMacros($edit_tpl,[
815 '$nametext' => DI::l10n()->t('New album name: '),
816 '$nickname' => $user['nickname'],
817 '$album' => $album_e,
818 '$hexalbum' => bin2hex($album),
819 '$submit' => DI::l10n()->t('Submit'),
820 '$dropsubmit' => DI::l10n()->t('Delete Album')
823 } elseif ($can_post) {
824 $edit = [DI::l10n()->t('Edit Album'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '/edit'];
825 $drop = [DI::l10n()->t('Drop Album'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '/drop'];
828 if ($order_field === 'created') {
829 $order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
831 $order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=created', 'newest'];
836 if (DBA::isResult($r)) {
837 // "Twist" is only used for the duepunto theme with style "slackr"
839 foreach ($r as $rr) {
842 $ext = $phototypes[$rr['type']];
844 $imgalt_e = $rr['filename'];
845 $desc_e = $rr['desc'];
849 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
850 'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id']
851 . ($order_field === 'created' ? '?order=created' : ''),
852 'title' => DI::l10n()->t('View Photo'),
853 'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
857 'hash'=> $rr['resource-id'],
862 $tpl = Renderer::getMarkupTemplate('photo_album.tpl');
863 $o .= Renderer::replaceMacros($tpl, [
864 '$photos' => $photos,
866 '$can_post' => $can_post,
867 '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
871 '$paginate' => $pager->renderFull($total),
879 if ($datatype === 'image') {
880 // fetch image, item containing image, then comments
881 $ph = Photo::selectToArray([], ["`uid` = ? AND `resource-id` = ? " . $sql_extra, $owner_uid, $datum], ['order' => ['scale']]);
883 if (!DBA::isResult($ph)) {
884 if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
885 DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied. Access to this item may be restricted.'));
887 DI::sysmsg()->addNotice(DI::l10n()->t('Photo not available'));
892 if ($cmd === 'drop') {
893 $drop_url = DI::args()->getQueryString();
895 return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
897 'message' => DI::l10n()->t('Do you really want to delete this photo?'),
898 'confirm' => DI::l10n()->t('Delete Photo'),
899 'cancel' => DI::l10n()->t('Cancel'),
902 '$confirm_url' => $drop_url,
903 '$confirm_name' => 'delete',
904 '$confirm_value' => 'delete',
912 * @todo This query is totally bad, the whole functionality has to be changed
913 * The query leads to a really intense used index.
914 * By now we hide it if someone wants to.
916 if ($cmd === 'view' && !DI::config()->get('system', 'no_count', false)) {
917 $order_field = $_GET['order'] ?? '';
919 if ($order_field === 'created') {
920 $params = ['order' => [$order_field]];
921 } elseif (!empty($order_field) && DBStructure::existsColumn('photo', [$order_field])) {
922 $params = ['order' => [$order_field => true]];
927 $prvnxt = Photo::selectToArray(['resource-id'], ["`album` = ? AND `uid` = ? AND `scale` = ?" . $sql_extra, $ph[0]['album'], $owner_uid, 0], $params);
929 if (DBA::isResult($prvnxt)) {
932 foreach ($prvnxt as $z => $entry) {
933 if ($entry['resource-id'] == $ph[0]['resource-id']) {
934 $prv = $order_field === 'created' ? $z - 1 : $z + 1;
935 $nxt = $order_field === 'created' ? $z + 1 : $z - 1;
937 $prv = count($prvnxt) - 1;
940 $nxt = count($prvnxt) - 1;
942 if ($prv >= count($prvnxt)) {
945 if ($nxt >= count($prvnxt)) {
952 if (!is_null($prv)) {
953 $prevlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'created' ? '?order=created' : '');
955 if (!is_null($nxt)) {
956 $nextlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'created' ? '?order=created' : '');
959 $tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
960 DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl,[
961 '$prevlink' => $prevlink,
962 '$nextlink' => $nextlink
966 $prevlink = [$prevlink, '<div class="icon prev"></div>'];
970 $nextlink = [$nextlink, '<div class="icon next"></div>'];
975 if (count($ph) == 1) {
976 $hires = $lores = $ph[0];
979 if (count($ph) > 1) {
980 if ($ph[1]['scale'] == 2) {
981 // original is 640 or less, we can display it directly
982 $hires = $lores = $ph[0];
989 $album_link = 'photos/' . $user['nickname'] . '/album/' . bin2hex($ph[0]['album']);
993 if ($can_post && ($ph[0]['uid'] == $owner_uid)) {
995 if ($cmd === 'edit') {
996 $tools['view'] = ['photos/' . $user['nickname'] . '/image/' . $datum, DI::l10n()->t('View photo')];
998 $tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
999 $tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
1000 $tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
1004 $ph[0]['uid'] == DI::userSession()->getLocalUserId()
1005 && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']))
1007 $tools['lock'] = DI::l10n()->t('Private Photo');
1012 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
1013 'title'=> DI::l10n()->t('View Full Size'),
1014 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?_u=' . DateTimeFormat::utcNow('ymdhis'),
1015 'height' => $hires['height'],
1016 'width' => $hires['width'],
1017 'album' => $hires['album'],
1018 'filename' => $hires['filename'],
1025 // Do we have an item for this photo?
1027 // FIXME! - replace following code to display the conversation with our normal
1028 // conversation functions so that it works correctly and tracks changes
1029 // in the evolving conversation code.
1030 // The difference is that we won't be displaying the conversation head item
1031 // as a "post" but displaying instead the photo it is linked to
1033 $link_item = Post::selectFirst([], ["`resource-id` = ?" . $sql_extra, $datum]);
1035 if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
1036 $condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
1037 $total = Post::count($condition);
1039 $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
1041 $params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
1042 $items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
1044 if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
1045 Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
1049 if (!empty($link_item['coord'])) {
1050 $map = Map::byCoordinates($link_item['coord']);
1055 if (!empty($link_item['id'])) {
1056 // parse tags and add links
1058 foreach (explode(',', Tag::getCSVByURIId($link_item['uri-id'])) as $tag_name) {
1061 'name' => BBCode::toPlaintext($tag_name),
1062 'removeurl' => 'post/' . $link_item['id'] . '/tag/remove/' . bin2hex($tag_name) . '?return=' . urlencode(DI::args()->getCommand()),
1066 $tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr];
1067 if ($cmd === 'edit') {
1068 $tags['removeanyurl'] = 'post/' . $link_item['id'] . '/tag/remove?return=' . urlencode(DI::args()->getCommand());
1069 $tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
1075 if ($cmd === 'edit' && $can_post) {
1076 $edit_tpl = Renderer::getMarkupTemplate('photo_edit.tpl');
1078 $album_e = $ph[0]['album'];
1079 $caption_e = $ph[0]['desc'];
1080 $aclselect_e = ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
1082 $edit = Renderer::replaceMacros($edit_tpl, [
1083 '$id' => $ph[0]['id'],
1084 '$album' => ['albname', DI::l10n()->t('New album name'), $album_e,''],
1085 '$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
1086 '$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
1087 '$rotate_none' => ['rotate', DI::l10n()->t('Do not rotate'),0,'', true],
1088 '$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"),1,''],
1089 '$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"),2,''],
1091 '$nickname' => $user['nickname'],
1092 '$resource_id' => $ph[0]['resource-id'],
1093 '$permissions' => DI::l10n()->t('Permissions'),
1094 '$aclselect' => $aclselect_e,
1096 '$item_id' => $link_item['id'] ?? 0,
1097 '$submit' => DI::l10n()->t('Submit'),
1098 '$delete' => DI::l10n()->t('Delete Photo'),
1100 // ACL permissions box
1101 '$return_path' => DI::args()->getQueryString(),
1111 if (!empty($link_item['id']) && !empty($link_item['uri'])) {
1112 $cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
1113 $tpl = Renderer::getMarkupTemplate('photo_item.tpl');
1114 $return_path = DI::args()->getCommand();
1116 if (!DBA::isResult($items)) {
1117 if (($can_post || Security::canWriteToUserWall($owner_uid))) {
1119 * Hmmm, code depending on the presence of a particular addon?
1120 * This should be better if done by a hook
1123 if (Addon::isEnabled('qcomment')) {
1124 $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
1125 $qcomment = $words ? explode("\n", $words) : [];
1128 $comments .= Renderer::replaceMacros($cmnt_tpl, [
1129 '$return_path' => '',
1130 '$jsreload' => $return_path,
1131 '$id' => $link_item['id'],
1132 '$parent' => $link_item['id'],
1133 '$profile_uid' => $owner_uid,
1134 '$mylink' => $contact['url'],
1135 '$mytitle' => DI::l10n()->t('This is you'),
1136 '$myphoto' => $contact['thumb'],
1137 '$comment' => DI::l10n()->t('Comment'),
1138 '$submit' => DI::l10n()->t('Submit'),
1139 '$preview' => DI::l10n()->t('Preview'),
1140 '$loading' => DI::l10n()->t('Loading...'),
1141 '$qcomment' => $qcomment,
1142 '$rand_num' => Crypto::randomDigits(12),
1155 if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
1156 unset($conv_responses['dislike']);
1160 if (DBA::isResult($items)) {
1161 foreach ($items as $item) {
1162 DI::conversation()->builtinActivityPuller($item, $conv_responses);
1165 if (!empty($conv_responses['like'][$link_item['uri']])) {
1166 $like = DI::conversation()->formatActivity($conv_responses['like'][$link_item['uri']]['links'], 'like', $link_item['id']);
1169 if (!empty($conv_responses['dislike'][$link_item['uri']])) {
1170 $dislike = DI::conversation()->formatActivity($conv_responses['dislike'][$link_item['uri']]['links'], 'dislike', $link_item['id']);
1173 if (($can_post || Security::canWriteToUserWall($owner_uid))) {
1175 * Hmmm, code depending on the presence of a particular addon?
1176 * This should be better if done by a hook
1179 if (Addon::isEnabled('qcomment')) {
1180 $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
1181 $qcomment = $words ? explode("\n", $words) : [];
1184 $comments .= Renderer::replaceMacros($cmnt_tpl,[
1185 '$return_path' => '',
1186 '$jsreload' => $return_path,
1187 '$id' => $link_item['id'],
1188 '$parent' => $link_item['id'],
1189 '$profile_uid' => $owner_uid,
1190 '$mylink' => $contact['url'],
1191 '$mytitle' => DI::l10n()->t('This is you'),
1192 '$myphoto' => $contact['thumb'],
1193 '$comment' => DI::l10n()->t('Comment'),
1194 '$submit' => DI::l10n()->t('Submit'),
1195 '$preview' => DI::l10n()->t('Preview'),
1196 '$qcomment' => $qcomment,
1197 '$rand_num' => Crypto::randomDigits(12),
1201 foreach ($items as $item) {
1205 $activity = DI::activity();
1207 if (($activity->match($item['verb'], Activity::LIKE) ||
1208 $activity->match($item['verb'], Activity::DISLIKE)) &&
1209 ($item['gravity'] != Item::GRAVITY_PARENT)) {
1213 $author = ['uid' => 0, 'id' => $item['author-id'],
1214 'network' => $item['author-network'], 'url' => $item['author-link']];
1215 $profile_url = Contact::magicLinkByContact($author);
1216 if (strpos($profile_url, 'contact/redir/') === 0) {
1217 $sparkle = ' sparkle';
1222 $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
1224 'dropping' => $dropping,
1225 'pagedrop' => false,
1226 'select' => DI::l10n()->t('Select'),
1227 'delete' => DI::l10n()->t('Delete'),
1230 $title_e = $item['title'];
1231 $body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
1233 $comments .= Renderer::replaceMacros($template,[
1234 '$id' => $item['id'],
1235 '$profile_url' => $profile_url,
1236 '$name' => $item['author-name'],
1237 '$thumb' => $item['author-avatar'],
1238 '$sparkle' => $sparkle,
1239 '$title' => $title_e,
1241 '$ago' => Temporal::getRelativeDate($item['created']),
1242 '$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
1244 '$comment' => $comment
1247 if (($can_post || Security::canWriteToUserWall($owner_uid))) {
1249 * Hmmm, code depending on the presence of a particular addon?
1250 * This should be better if done by a hook
1253 if (Addon::isEnabled('qcomment')) {
1254 $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
1255 $qcomment = $words ? explode("\n", $words) : [];
1258 $comments .= Renderer::replaceMacros($cmnt_tpl, [
1259 '$return_path' => '',
1260 '$jsreload' => $return_path,
1261 '$id' => $item['id'],
1262 '$parent' => $item['parent'],
1263 '$profile_uid' => $owner_uid,
1264 '$mylink' => $contact['url'],
1265 '$mytitle' => DI::l10n()->t('This is you'),
1266 '$myphoto' => $contact['thumb'],
1267 '$comment' => DI::l10n()->t('Comment'),
1268 '$submit' => DI::l10n()->t('Submit'),
1269 '$preview' => DI::l10n()->t('Preview'),
1270 '$qcomment' => $qcomment,
1271 '$rand_num' => Crypto::randomDigits(12),
1278 foreach ($conv_responses as $verb => $activity) {
1279 if (isset($activity[$link_item['uri']])) {
1280 $responses[$verb] = $activity[$link_item['uri']];
1284 if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
1285 $like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
1286 $likebuttons = Renderer::replaceMacros($like_tpl, [
1287 '$id' => $link_item['id'],
1288 '$like' => DI::l10n()->t('Like'),
1289 '$like_title' => DI::l10n()->t('I like this (toggle)'),
1290 '$dislike' => DI::l10n()->t('Dislike'),
1291 '$wait' => DI::l10n()->t('Please wait'),
1292 '$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
1293 '$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
1294 '$responses' => $responses,
1295 '$return_path' => DI::args()->getQueryString(),
1299 $paginate = $pager->renderFull($total);
1302 $photo_tpl = Renderer::getMarkupTemplate('photo_view.tpl');
1303 $o .= Renderer::replaceMacros($photo_tpl, [
1304 '$id' => $ph[0]['id'],
1305 '$album' => [$album_link, $ph[0]['album']],
1308 '$prevlink' => $prevlink,
1309 '$nextlink' => $nextlink,
1310 '$desc' => $ph[0]['desc'],
1314 '$map_text' => DI::l10n()->t('Map'),
1315 '$likebuttons' => $likebuttons,
1317 '$dislike' => $dislike,
1318 '$comments' => $comments,
1319 '$paginate' => $paginate,
1322 DI::page()['htmlhead'] .= "\n" . '<meta name="twitter:card" content="summary_large_image" />' . "\n";
1323 DI::page()['htmlhead'] .= '<meta name="twitter:title" content="' . $photo["album"] . '" />' . "\n";
1324 DI::page()['htmlhead'] .= '<meta name="twitter:image" content="' . DI::baseUrl() . "/" . $photo["href"] . '" />' . "\n";
1325 DI::page()['htmlhead'] .= '<meta name="twitter:image:width" content="' . $photo["width"] . '" />' . "\n";
1326 DI::page()['htmlhead'] .= '<meta name="twitter:image:height" content="' . $photo["height"] . '" />' . "\n";