]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
extend checkbox template for customized attributes
[friendica.git] / mod / photos.php
index ddef07000ae57a7c5a2fd5c386db400812517da9..6c9f4bd66214bcbd1d05aac08c5ab3cd16079f1f 100644 (file)
@@ -1,16 +1,19 @@
 <?php
-require_once('include/Photo.php');
-require_once('include/photos.php');
-require_once('include/items.php');
-require_once('include/acl_selectors.php');
-require_once('include/bbcode.php');
-require_once('include/security.php');
-require_once('include/redir.php');
-require_once('include/tags.php');
-require_once('include/threads.php');
-require_once('include/Probe.php');
-
-use \Friendica\Core\Config;
+
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Core\Config;
+use Friendica\Network\Probe;
+
+require_once 'include/Photo.php';
+require_once 'include/photos.php';
+require_once 'include/items.php';
+require_once 'include/acl_selectors.php';
+require_once 'include/bbcode.php';
+require_once 'include/security.php';
+require_once 'include/redir.php';
+require_once 'include/tags.php';
+require_once 'include/threads.php';
 
 function photos_init(App $a) {
 
@@ -26,7 +29,7 @@ function photos_init(App $a) {
 
        if ($a->argc > 1) {
                $nick = $a->argv[1];
-               $user = qu("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
+               $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
                        dbesc($nick)
                );
 
@@ -93,7 +96,7 @@ function photos_init(App $a) {
                                '$title'    => t('Photo Albums'),
                                '$recent'   => t('Recent Photos'),
                                '$albums'   => $albums['albums'],
-                               '$baseurl'  => z_root(),
+                               '$baseurl'  => System::baseUrl(),
                                '$upload'   => array(t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'),
                                '$can_post' => $can_post
                        ));
@@ -150,7 +153,7 @@ function photos_post(App $a) {
                        }
                        if ($contact_id) {
 
-                               $r = qu("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
+                               $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
                                        intval($contact_id),
                                        intval($page_owner_uid)
                                );
@@ -167,7 +170,7 @@ function photos_post(App $a) {
                killme();
        }
 
-       $r = qu("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
+       $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
                WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
                intval($page_owner_uid)
        );
@@ -189,7 +192,7 @@ function photos_post(App $a) {
                        return; // NOTREACHED
                }
 
-               $r = qu("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
+               $r = q("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
                        dbesc($album),
                        intval($page_owner_uid)
                );
@@ -371,7 +374,7 @@ function photos_post(App $a) {
                                create_tags_from_itemuri($i[0]['uri'], $page_owner_uid);
                                delete_thread_uri($i[0]['uri'], $page_owner_uid);
 
-                               $url = App::get_baseurl();
+                               $url = System::baseUrl();
                                $drop_id = intval($i[0]['id']);
 
                                // Update the photo albums cache
@@ -523,8 +526,8 @@ function photos_post(App $a) {
                        $arr['visible']       = $visibility;
                        $arr['origin']        = 1;
 
-                       $arr['body']          = '[url=' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
-                                               . '[img]' . App::get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
+                       $arr['body']          = '[url=' . System::baseUrl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
+                                               . '[img]' . System::baseUrl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
                                                . '[/url]';
 
                        $item_id = item_store($arr);
@@ -638,7 +641,7 @@ function photos_post(App $a) {
                                                }
                                        } elseif (strpos($tag, '#') === 0) {
                                                $tagname = substr($tag, 1);
-                                               $str_tags .= '#[url=' . App::get_baseurl() . "/search?tag=" . $tagname . ']' . $tagname . '[/url]';
+                                               $str_tags .= '#[url=' . System::baseUrl() . "/search?tag=" . $tagname . ']' . $tagname . '[/url]';
                                        }
                                }
                        }
@@ -710,8 +713,8 @@ function photos_post(App $a) {
                                        $arr['tag']           = $tagged[4];
                                        $arr['inform']        = $tagged[2];
                                        $arr['origin']        = 1;
-                                       $arr['body']          = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
-                                       $arr['body'] .= "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
+                                       $arr['body']          = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
+                                       $arr['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . System::baseUrl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
 
                                        $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
                                        $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
@@ -721,8 +724,8 @@ function photos_post(App $a) {
                                        $arr['object'] .= '</link></object>' . "\n";
 
                                        $arr['target'] = '<target><type>' . ACTIVITY_OBJ_IMAGE . '</type><title>' . $p[0]['desc'] . '</title><id>'
-                                               . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
-                                       $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
+                                               . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
+                                       $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . System::baseUrl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
 
                                        $item_id = item_store($arr);
                                        if ($item_id) {
@@ -861,7 +864,7 @@ function photos_post(App $a) {
        $exif = $ph->orient($src);
        @unlink($src);
 
-       $max_length = get_config('system','max_image_length');
+       $max_length = get_config('system', 'max_image_length');
        if (! $max_length) {
                $max_length = MAX_IMAGE_LENGTH;
        }
@@ -940,8 +943,8 @@ function photos_post(App $a) {
        $arr['visible']       = $visible;
        $arr['origin']        = 1;
 
-       $arr['body']          = '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
-                               . '[img]' . App::get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
+       $arr['body']          = '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
+                               . '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
                                . '[/url]';
 
        $item_id = item_store($arr);
@@ -980,9 +983,9 @@ function photos_content(App $a) {
                return;
        }
 
-       require_once('include/bbcode.php');
-       require_once('include/security.php');
-       require_once('include/conversation.php');
+       require_once 'include/bbcode.php';
+       require_once 'include/security.php';
+       require_once 'include/conversation.php';
 
        if (! x($a->data,'user')) {
                notice( t('No photos selected') . EOL );
@@ -1098,7 +1101,7 @@ function photos_content(App $a) {
 
        // tabs
        $is_owner = (local_user() && (local_user() == $owner_uid));
-       $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
+       $o .= profile_tabs($a, $is_owner, $a->data['user']['nickname']);
 
        /**
         * Display upload form
@@ -1240,7 +1243,10 @@ function photos_content(App $a) {
                        $order = 'DESC';
                }
 
-               $r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
+               $r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
+                       ANY_VALUE(`type`) AS `type`, max(`scale`) AS `scale`, ANY_VALUE(`desc`) as `desc`,
+                       ANY_VALUE(`created`) as `created`
+                       FROM `photo` WHERE `uid` = %d AND `album` = '%s'
                        AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` $order LIMIT %d , %d",
                        intval($owner_uid),
                        dbesc($album),
@@ -1271,11 +1277,8 @@ function photos_content(App $a) {
                                }
                        }
                } else {
-                       /// @TODO merge else+if into elseif and 2 into one?
-                       if (($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
-                               if ($can_post) {
-                                       $edit = array(t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit');
-                               }
+                       if (($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos')) && $can_post) {
+                               $edit = array(t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit');
                        }
                }
 
@@ -1375,7 +1378,7 @@ function photos_content(App $a) {
                        else
                                $order = 'DESC';
 
-                       $prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
+                       $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
                                $sql_extra ORDER BY `created` $order ",
                                dbesc($ph[0]['album']),
                                intval($owner_uid)
@@ -1475,7 +1478,7 @@ function photos_content(App $a) {
                if (dbm::is_result($linked_items)) {
                        $link_item = $linked_items[0];
 
-                       $r = qu("SELECT COUNT(*) AS `total`
+                       $r = q("SELECT COUNT(*) AS `total`
                                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                                WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
@@ -1492,7 +1495,7 @@ function photos_content(App $a) {
                        }
 
 
-                       $r = qu("SELECT `item`.*, `item`.`id` AS `item_id`,
+                       $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
                                `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
                                `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
                                `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
@@ -1584,9 +1587,9 @@ function photos_content(App $a) {
                                '$album' => array('albname', t('New album name'), $album_e,''),
                                '$caption' => array('desc', t('Caption'), $caption_e, ''),
                                '$tags' => array('newtag', t('Add a Tag'), "", t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')),
-                               '$rotate_none' => array('rotate',t('Do not rotate'),0,'', true),
-                               '$rotate_cw' => array('rotate',t('Rotate CW (right)'),1,''),
-                               '$rotate_ccw' => array('rotate',t('Rotate CCW (left)'),2,''),
+                               '$rotate_none' => array('rotate', t('Do not rotate'),0,'', true),
+                               '$rotate_cw' => array('rotate', t('Rotate CW (right)'),1,''),
+                               '$rotate_ccw' => array('rotate', t('Rotate CCW (left)'),2,''),
 
                                '$nickname' => $a->data['user']['nickname'],
                                '$resource_id' => $ph[0]['resource-id'],
@@ -1619,8 +1622,8 @@ function photos_content(App $a) {
 
                        $likebuttons = '';
 
-                       if ($can_post || can_write_wall($a,$owner_uid)) {
-                               $likebuttons = replace_macros($like_tpl,array(
+                       if ($can_post || can_write_wall($a, $owner_uid)) {
+                               $likebuttons = replace_macros($like_tpl, array(
                                        '$id' => $link_item['id'],
                                        '$likethis' => t("I like this \x28toggle\x29"),
                                        '$nolike' => (feature_enabled(local_user(), 'dislike') ? t("I don't like this \x28toggle\x29") : ''),
@@ -1631,27 +1634,24 @@ function photos_content(App $a) {
 
                        $comments = '';
                        if (! dbm::is_result($r)) {
-                               /// @TODO merge into one if() ?
-                               if ($can_post || can_write_wall($a,$owner_uid)) {
-                                       if ($link_item['last-child']) {
-                                               $comments .= replace_macros($cmnt_tpl,array(
-                                                       '$return_path' => '',
-                                                       '$jsreload' => $return_url,
-                                                       '$type' => 'wall-comment',
-                                                       '$id' => $link_item['id'],
-                                                       '$parent' => $link_item['id'],
-                                                       '$profile_uid' =>  $owner_uid,
-                                                       '$mylink' => $contact['url'],
-                                                       '$mytitle' => t('This is you'),
-                                                       '$myphoto' => $contact['thumb'],
-                                                       '$comment' => t('Comment'),
-                                                       '$submit' => t('Submit'),
-                                                       '$preview' => t('Preview'),
-                                                       '$sourceapp' => t($a->sourcename),
-                                                       '$ww' => '',
-                                                       '$rand_num' => random_digits(12)
-                                               ));
-                                       }
+                               if (($can_post || can_write_wall($a, $owner_uid)) && $link_item['last-child']) {
+                                       $comments .= replace_macros($cmnt_tpl, array(
+                                               '$return_path' => '',
+                                               '$jsreload' => $return_url,
+                                               '$type' => 'wall-comment',
+                                               '$id' => $link_item['id'],
+                                               '$parent' => $link_item['id'],
+                                               '$profile_uid' =>  $owner_uid,
+                                               '$mylink' => $contact['url'],
+                                               '$mytitle' => t('This is you'),
+                                               '$myphoto' => $contact['thumb'],
+                                               '$comment' => t('Comment'),
+                                               '$submit' => t('Submit'),
+                                               '$preview' => t('Preview'),
+                                               '$sourceapp' => t($a->sourcename),
+                                               '$ww' => '',
+                                               '$rand_num' => random_digits(12)
+                                       ));
                                }
                        }
 
@@ -1673,30 +1673,27 @@ function photos_content(App $a) {
                                        builtin_activity_puller($item, $conv_responses);
                                }
 
-                               $like    = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'], 'like',$link_item['id']) : '');
-                               $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike',$link_item['id']) : '');
-
-                               /// @TODO merge into one if() ?
-                               if ($can_post || can_write_wall($a,$owner_uid)) {
-                                       if ($link_item['last-child']) {
-                                               $comments .= replace_macros($cmnt_tpl,array(
-                                                       '$return_path' => '',
-                                                       '$jsreload' => $return_url,
-                                                       '$type' => 'wall-comment',
-                                                       '$id' => $link_item['id'],
-                                                       '$parent' => $link_item['id'],
-                                                       '$profile_uid' =>  $owner_uid,
-                                                       '$mylink' => $contact['url'],
-                                                       '$mytitle' => t('This is you'),
-                                                       '$myphoto' => $contact['thumb'],
-                                                       '$comment' => t('Comment'),
-                                                       '$submit' => t('Submit'),
-                                                       '$preview' => t('Preview'),
-                                                       '$sourceapp' => t($a->sourcename),
-                                                       '$ww' => '',
-                                                       '$rand_num' => random_digits(12)
-                                               ));
-                                       }
+                               $like    = ((x($conv_responses['like'], $link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']], $conv_responses['like'][$link_item['uri'] . '-l'], 'like',$link_item['id']) : '');
+                               $dislike = ((x($conv_responses['dislike'], $link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']], $conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike',$link_item['id']) : '');
+
+                               if (($can_post || can_write_wall($a, $owner_uid)) && $link_item['last-child']) {
+                                       $comments .= replace_macros($cmnt_tpl,array(
+                                               '$return_path' => '',
+                                               '$jsreload' => $return_url,
+                                               '$type' => 'wall-comment',
+                                               '$id' => $link_item['id'],
+                                               '$parent' => $link_item['id'],
+                                               '$profile_uid' =>  $owner_uid,
+                                               '$mylink' => $contact['url'],
+                                               '$mytitle' => t('This is you'),
+                                               '$myphoto' => $contact['thumb'],
+                                               '$comment' => t('Comment'),
+                                               '$submit' => t('Submit'),
+                                               '$preview' => t('Preview'),
+                                               '$sourceapp' => t($a->sourcename),
+                                               '$ww' => '',
+                                               '$rand_num' => random_digits(12)
+                                       ));
                                }
 
 
@@ -1759,27 +1756,24 @@ function photos_content(App $a) {
                                                '$comment' => $comment
                                        ));
 
-                                       /// @TODO merge into one if() ?
-                                       if ($can_post || can_write_wall($a, $owner_uid)) {
-                                               if ($item['last-child']) {
-                                                       $comments .= replace_macros($cmnt_tpl, array(
-                                                               '$return_path' => '',
-                                                               '$jsreload' => $return_url,
-                                                               '$type' => 'wall-comment',
-                                                               '$id' => $item['item_id'],
-                                                               '$parent' => $item['parent'],
-                                                               '$profile_uid' =>  $owner_uid,
-                                                               '$mylink' => $contact['url'],
-                                                               '$mytitle' => t('This is you'),
-                                                               '$myphoto' => $contact['thumb'],
-                                                               '$comment' => t('Comment'),
-                                                               '$submit' => t('Submit'),
-                                                               '$preview' => t('Preview'),
-                                                               '$sourceapp' => t($a->sourcename),
-                                                               '$ww' => '',
-                                                               '$rand_num' => random_digits(12)
-                                                       ));
-                                               }
+                                       if (($can_post || can_write_wall($a, $owner_uid)) && $item['last-child']) {
+                                               $comments .= replace_macros($cmnt_tpl, array(
+                                                       '$return_path' => '',
+                                                       '$jsreload' => $return_url,
+                                                       '$type' => 'wall-comment',
+                                                       '$id' => $item['item_id'],
+                                                       '$parent' => $item['parent'],
+                                                       '$profile_uid' =>  $owner_uid,
+                                                       '$mylink' => $contact['url'],
+                                                       '$mytitle' => t('This is you'),
+                                                       '$myphoto' => $contact['thumb'],
+                                                       '$comment' => t('Comment'),
+                                                       '$submit' => t('Submit'),
+                                                       '$preview' => t('Preview'),
+                                                       '$sourceapp' => t($a->sourcename),
+                                                       '$ww' => '',
+                                                       '$rand_num' => random_digits(12)
+                                               ));
                                        }
                                }
                        }
@@ -1789,9 +1783,10 @@ function photos_content(App $a) {
 
 
                $response_verbs = array('like');
-               if (feature_enabled($owner_uid,'dislike'))
+               if (feature_enabled($owner_uid, 'dislike')) {
                        $response_verbs[] = 'dislike';
-               $responses = get_responses($conv_responses,$response_verbs,'',$link_item);
+               }
+               $responses = get_responses($conv_responses,$response_verbs, '', $link_item);
 
                $photo_tpl = get_markup_template('photo_view.tpl');
 
@@ -1801,7 +1796,7 @@ function photos_content(App $a) {
                        $like_e = template_escape($like);
                        $dislike_e = template_escape($dislike);
                } else {
-                       $album_e = array($album_link,$ph[0]['album']);
+                       $album_e = array($album_link, $ph[0]['album']);
                        $tags_e = $tags;
                        $like_e = $like;
                        $dislike_e = $dislike;
@@ -1828,11 +1823,11 @@ function photos_content(App $a) {
                        '$paginate' => $paginate,
                ));
 
-               $a->page['htmlhead'] .= "\n".'<meta name="twitter:card" content="photo" />'."\n";
-               $a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$photo["album"].'" />'."\n";
-               $a->page['htmlhead'] .= '<meta name="twitter:image" content="'.$photo["href"].'" />'."\n";
-               $a->page['htmlhead'] .= '<meta name="twitter:image:width" content="'.$photo["width"].'" />'."\n";
-               $a->page['htmlhead'] .= '<meta name="twitter:image:height" content="'.$photo["height"].'" />'."\n";
+               $a->page['htmlhead'] .= "\n" . '<meta name="twitter:card" content="photo" />' . "\n";
+               $a->page['htmlhead'] .= '<meta name="twitter:title" content="' . $photo["album"] . '" />' . "\n";
+               $a->page['htmlhead'] .= '<meta name="twitter:image" content="' . $photo["href"] . '" />' . "\n";
+               $a->page['htmlhead'] .= '<meta name="twitter:image:width" content="' . $photo["width"] . '" />' . "\n";
+               $a->page['htmlhead'] .= '<meta name="twitter:image:height" content="' . $photo["height"] . '" />' . "\n";
 
                return $o;
        }
@@ -1840,7 +1835,7 @@ function photos_content(App $a) {
        // Default - show recent photos with upload link (if applicable)
        //$o = '';
 
-       $r = qu("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
+       $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
                $sql_extra GROUP BY `resource-id`",
                intval($a->data['user']['uid']),
                dbesc('Contact Photos'),
@@ -1851,7 +1846,9 @@ function photos_content(App $a) {
                $a->set_pager_itemspage(20);
        }
 
-       $r = qu("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
+       $r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
+               ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`,
+               ANY_VALUE(`created`) AS `created` FROM `photo`
                WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
                $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
                intval($a->data['user']['uid']),