add photo widget

This commit is contained in:
friendica 2014-05-13 21:33:39 -07:00
parent 2f5bd7e1b3
commit b0dc3d3b4c
2 changed files with 57 additions and 10 deletions

View File

@ -6,21 +6,19 @@ Some/many of these widgets have restrictions which may restrict the type of page
* clock - displays the current time
* args: military (1 or 0) - use 24 hour time as opposed to AM/PM
*
<br />&nbsp;<br />
* profile - displays a profile sidebar on pages which load profiles (pages with nickname in the URL)
* tagcloud - display a tagcloud of webpage items
* args: count - number of items to return (default 24)
*
<br />&nbsp;<br />
* collections - collection selector for the current logged in channel
* args: mode - one of "conversation", "group", "abook" depending on module
*
<br />&nbsp;<br />
* suggestions - friend suggestions for the current logged on channel
@ -34,8 +32,7 @@ Some/many of these widgets have restrictions which may restrict the type of page
* archive - date range selector for network and channel pages
* args: 'wall' - 1 or 0, limit to wall posts or network/matrix posts (default)
* 'style': 'list' or 'select' - presentation format, a select form element or a list, default 'select'
*
<br />&nbsp;<br />
* fullprofile - same as profile currently
@ -69,8 +66,16 @@ Some/many of these widgets have restrictions which may restrict the type of page
* bookmarkedchats - list of bookmarked chatrooms collected on this site for the current observer
* suggestechats - "interesting" chatrooms chosen for the current observer
* suggestedchats - "interesting" chatrooms chosen for the current observer
* item - displays a single webpage item by mid
1 args: mid - message_id of webpage to display
* args: mid - message_id of webpage to display
<br />&nbsp;<br />
* photo - display a single photo
* args:
* url - URL of photo, must be http or https
* zrl - use zid authenticated link
* style - CSS style string
<br />&nbsp;<br />

View File

@ -719,4 +719,46 @@ $(document).ready(function() {
EOT;
return $o;
}
}
/**
* @function widget_photo($arr)
* widget to display a single photo.
* @param array $arr;
* 'src' => URL of photo
* 'zrl' => true or false, use zid in url
* 'style' => CSS string
* URL must be an http or https URL
*/
function widget_photo($arr) {
$style = $zrl = false;
$params = '';
if(array_key_exists('src',$arr) && isset($arr['src']))
$url = $arr['src'];
if(strpos($url,'http') !== 0)
return '';
if(array_key_exists('style',$arr) && isset($arr['style']))
$style = $arr['style'];
if(array_key_exists('zrl',$arr) && isset($arr['zrl']))
$zrl = (($arr['zrl']) ? true : false);
if($zrl)
$url = zid($url);
$o = '<div class="widget">';
$o .= '<img ' . (($zrl) ? ' class="zrl" ' : '')
. (($style) ? ' style="' . $style . '"' : '')
. ' src="' . $url . '" />';
$o .= '</div>';
return $o;
}