make embedded photos work for site logo and cover photo

This commit is contained in:
nobody 2020-09-09 20:52:42 -07:00
parent 2e4fd68c07
commit fcb7933c85
5 changed files with 28 additions and 13 deletions

View file

@ -365,6 +365,7 @@ logger('gis: ' . print_r($gis,true));
$o .= replace_macros(get_markup_template('admin_cover_photo.tpl'), [
'$user' => $channel['channel_address'],
'$channel_id' => $channel['channel_id'],
'$info' => t('Your cover photo may be visible to anybody on the internet'),
'$existing' => get_cover_photo($channel['channel_id'],'array',PHOTO_RES_COVER_850),
'$lbl_upfile' => t('Upload File:'),

View file

@ -455,6 +455,7 @@ class Profile_photo {
$o .= replace_macros($tpl, [
'$user' => $channel['channel_address'],
'$channel_id' => $channel['channel_id'],
'$info' => ((count($profiles) > 1) ? t('Your default profile photo is visible to anybody on the internet. Profile photos for alternate profiles will inherit the permissions of the profile') : t('Your site photo is visible to anybody on the internet and may be distributed to other websites.')),
'$importfile' => (($importing) ? App::$data['importfile'] : ''),
'$lbl_upfile' => t('Upload File:'),

View file

@ -16,18 +16,24 @@ class Embedphotos extends Controller {
*
*/
function post() {
if (argc() > 2 && is_site_admin() && intval(argv(2))) {
$channel_id = argv(2);
}
else {
$channel_id = local_channel();
}
if (argc() > 1 && argv(1) === 'album') {
// API: /embedphotos/album
$name = (x($_POST,'name') ? $_POST['name'] : null );
if (! $name) {
json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false));
}
$album = $this->embedphotos_widget_album(array('channel_id' => local_channel(), 'album' => $name));
$album = $this->embedphotos_widget_album(array('channel_id' => $channel_id, 'album' => $name));
json_return_and_die(array('status' => true, 'content' => $album));
}
if (argc() > 1 && argv(1) === 'albumlist') {
// API: /embedphotos/albumlist
$album_list = $this->embedphotos_album_list();
$album_list = $this->embedphotos_album_list($channel_id);
json_return_and_die(array('status' => true, 'albumlist' => $album_list));
}
if (argc() > 1 && argv(1) === 'photolink') {
@ -38,7 +44,7 @@ class Embedphotos extends Controller {
}
$resource_id = array_pop(explode("/", $href));
$x = self::photolink($resource_id);
$x = self::photolink($resource_id, $channel_id);
if ($x) {
json_return_and_die(array('status' => true, 'photolink' => $x, 'resource_id' => $resource_id));
}
@ -48,8 +54,14 @@ class Embedphotos extends Controller {
}
protected static function photolink($resource) {
$channel = App::get_channel();
protected static function photolink($resource, $channel_id = 0) {
if (intval($channel_id)) {
$channel = channelx_by_n($channel_id);
}
else {
$channel = App::get_channel();
}
$output = EMPTY_STR;
if ($channel) {
$resolution = ((feature_enabled($channel['channel_id'],'large_photos')) ? 1 : 2);
@ -216,8 +228,9 @@ class Embedphotos extends Controller {
return $o;
}
function embedphotos_album_list() {
$p = photos_albums_list(App::get_channel(),App::get_observer());
function embedphotos_album_list($channel_id) {
$channel = channelx_by_n($channel_id);
$p = photos_albums_list($channel,App::get_observer());
if ($p['success']) {
return $p['albums'];
}

View file

@ -14,7 +14,7 @@
};
var choosePhotoFromAlbum = function (album) {
$.post("embedphotos/album", {name: album},
$.post("embedphotos/album/{{$channel_id}}", {name: album},
function(data) {
if (data['status']) {
$('#embedPhotoModalLabel').html("{{$modalchooseimages}}");
@ -34,7 +34,7 @@
var imageparent = document.getElementById($(image).parent()[0].id);
$(imageparent).toggleClass('embed-photo-selected-photo');
var href = $(imageparent).attr('href');
$.post("embedphotos/photolink", {href: href},
$.post("embedphotos/photolink/{{$channel_id}}", {href: href},
function(ddata) {
if (ddata['status']) {
window.location.href = 'admin/cover_photo/use/' + ddata['resource_id'];
@ -61,7 +61,7 @@
};
var getPhotoAlbumList = function () {
$.post("embedphotos/albumlist", {},
$.post("embedphotos/albumlist/{{$channel_id}}", {},
function(data) {
if (data['status']) {
var albums = data['albumlist']; //JSON.parse(data['albumlist']);

View file

@ -14,7 +14,7 @@
};
var choosePhotoFromAlbum = function (album) {
$.post("embedphotos/album", {name: album},
$.post("embedphotos/album/{{$channel_id}}", {name: album},
function(data) {
if (data['status']) {
$('#embedPhotoModalLabel').html("{{$modalchooseimages}}");
@ -34,7 +34,7 @@
var imageparent = document.getElementById($(image).parent()[0].id);
$(imageparent).toggleClass('embed-photo-selected-photo');
var href = $(imageparent).attr('href');
$.post("embedphotos/photolink", {href: href},
$.post("embedphotos/photolink/{{$channel_id}}", {href: href},
function(ddata) {
if (ddata['status']) {
var pf = $('#profile-photo-profiles').val();
@ -63,7 +63,7 @@
};
var getPhotoAlbumList = function () {
$.post("embedphotos/albumlist", {},
$.post("embedphotos/albumlist/{{$channel_id}}", {},
function(data) {
if (data['status']) {
var albums = data['albumlist']; //JSON.parse(data['albumlist']);