本文整理汇总了PHP中Media::getImageWH方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::getImageWH方法的具体用法?PHP Media::getImageWH怎么用?PHP Media::getImageWH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::getImageWH方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MG_profileblocksdisplay
function MG_profileblocksdisplay($uid)
{
global $_TABLES, $_MG_CONF, $_CONF, $LANG_MG10, $_USER;
$retval = '';
if ($_MG_CONF['profile_hook'] != 1) {
return '';
}
if ((!isset($_USER['uid']) || $_USER['uid'] < 2) && $_MG_CONF['loginrequired'] == 1) {
return '';
}
if (empty($uid)) {
return '';
}
$username = DB_getItem($_TABLES['users'], 'username', 'uid=' . intval($uid));
if (empty($username)) {
return '';
}
$T = COM_newTemplate(MG_getTemplatePath(0));
$T->set_file('mblock', 'profile_media.thtml');
$T->set_block('mblock', 'itemRow', 'iRow');
$T->set_var('start_block_last10mediaitems', COM_startBlock($LANG_MG10['last_10'] . $username));
$T->set_var('start_block_useralbums', COM_startBlock($LANG_MG10['albums_owned'] . $username));
$T->set_var('lang_thumbnail', $LANG_MG10['thumbnail']);
$T->set_var('lang_title', $LANG_MG10['title']);
$T->set_var('lang_album', $LANG_MG10['album']);
$T->set_var('lang_album_description', $LANG_MG10['album_desc']);
$T->set_var('lang_upload_date', $LANG_MG10['upload_date']);
$T->set_var('end_block', COM_endBlock());
$sql = "SELECT a.album_id,m.media_upload_time,m.media_id,m.media_filename,m.mime_type," . "m.media_mime_ext,m.media_title,m.remote_media,m.media_type,m.media_tn_attached " . "FROM {$_TABLES['mg_albums']} AS a LEFT JOIN {$_TABLES['mg_media_albums']} AS ma " . "ON a.album_id=ma.album_id LEFT JOIN {$_TABLES['mg_media']} AS m ON ma.media_id=m.media_id " . "WHERE m.media_user_id=" . intval($uid) . " AND a.hidden=0 " . COM_getPermSQL('and') . " ORDER BY m.media_upload_time DESC LIMIT 5";
$result = DB_query($sql);
$class = 0;
$mCount = 0;
while ($row = DB_fetchArray($result)) {
$album_id = $row['album_id'];
$album_data = MG_getAlbumData($album_id, array('album_title'));
$album_title = strip_tags($album_data['album_title']);
$upload_time = MG_getUserDateTimeFormat($row['media_upload_time']);
$url_media = $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'];
$url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id;
$tn_size = 10;
list($url_thumb, $p_thumb, $msize) = Media::getThumbInfo($row, $tn_size);
$atnsize = '';
if ($msize != false) {
list($newwidth, $newheight) = Media::getImageWH($msize[0], $msize[1], 50, 50);
$atnsize = 'width="' . $newwidth . '" height="' . $newheight . '" ';
}
$T->set_var('mediaitem_image', '<img src="' . $url_thumb . '" alt="" ' . $atnsize . 'style="border:none;vertical-align:bottom;"' . XHTML . '>');
$T->set_var('mediaitem_begin_href', '<a href="' . $url_media . '">');
$T->set_var('mediaitem_title', strip_tags($row['media_title']));
$T->set_var('mediaitem_end_href', '</a>');
$T->set_var('mediaitem_album_begin_href', '<a href="' . $url_album . '">');
$T->set_var('mediaitem_album_title', $album_title);
$T->set_var('mediaitem_date', $upload_time[0]);
$T->set_var('rowclass', $class % 2 ? '1' : '2');
$T->parse('iRow', 'itemRow', true);
$class++;
$mCount++;
}
if ($mCount != 0) {
$retval .= $T->finish($T->parse('output', 'mblock'));
}
$T = COM_newTemplate(MG_getTemplatePath(0));
$T->set_file('ablock', 'profile_album.thtml');
$T->set_block('ablock', 'itemRow', 'iRow');
$T->set_var('start_block_useralbums', COM_startBlock($LANG_MG10['albums_owned'] . $username));
$T->set_var('lang_thumbnail', $LANG_MG10['thumbnail']);
$T->set_var('lang_album', $LANG_MG10['album']);
$T->set_var('lang_album_description', $LANG_MG10['album_desc']);
$T->set_var('end_block', COM_endBlock());
$sql = "SELECT album_id,album_title,album_desc,tn_attached " . "FROM " . $_TABLES['mg_albums'] . " WHERE owner_id=" . intval($uid) . " AND hidden=0 " . COM_getPermSQL('and') . " ORDER BY last_update DESC LIMIT 10";
$result = DB_query($sql);
$class = 0;
$aCount = 0;
while ($row = DB_fetchArray($result)) {
$aid = $row['album_id'];
$url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $row['album_id'];
$url_thumb = '';
$msize = false;
if ($row['tn_attached'] == 1) {
list($url_thumb, $msize) = MG_getImageUrl('covers/cover_' . $row['album_id']);
} else {
$cover_file = MG_getAlbumCover($aid);
if ($cover_file != '') {
$offset = substr($cover_file, 0, 3) == 'tn_' ? 3 : 0;
list($url_thumb, $msize) = MG_getImageUrl('tn/' . $cover_file[$offset] . '/' . $cover_file);
}
}
if ($msize == false || $url_thumb == '') {
$url_thumb = $_MG_CONF['mediaobjects_url'] . '/empty.png';
$msize = getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png');
}
$atnsize = '';
if ($msize != false) {
list($newwidth, $newheight) = Media::getImageWH($msize[0], $msize[1], 50, 50);
$atnsize = 'width="' . $newwidth . '" height="' . $newheight . '" ';
}
$T->set_var('album_cover', '<img src="' . $url_thumb . '" alt="" ' . $atnsize . 'style="border:none;vertical-align:bottom;"' . XHTML . '>');
$T->set_var('album_begin_href', '<a href="' . $url_album . '">');
$T->set_var('album_title', strip_tags($row['album_title']));
$T->set_var('album_end_href', '</a>');
//.........这里部分代码省略.........
示例2: MG_mediaEdit
function MG_mediaEdit($album_id, $media_id, $actionURL = '', $mqueue = 0, $view = 0, $back = '')
{
global $_USER, $_CONF, $_MG_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG07, $_DB_dbms;
$album = new mgAlbum($album_id);
if ($actionURL == '') {
$actionURL = $_MG_CONF['site_url'] . '/index.php';
}
$retval = '';
$T = COM_newTemplate(MG_getTemplatePath($album_id));
$T->set_file(array('admin' => 'mediaedit.thtml', 'asf_options' => 'edit_asf_options.thtml', 'mp3_options' => 'edit_mp3_options.thtml', 'swf_options' => 'edit_swf_options.thtml', 'mov_options' => 'edit_mov_options.thtml', 'flv_options' => 'edit_flv_options.thtml'));
// pull the media information from the database...
$sql = "SELECT * FROM ";
if ($_DB_dbms == "mssql") {
$sql = "SELECT *,CAST(media_desc AS TEXT) AS media_desc FROM ";
}
$sql .= ($mqueue ? $_TABLES['mg_mediaqueue'] : $_TABLES['mg_media']) . " WHERE media_id='" . addslashes($media_id) . "'";
$result = DB_query($sql);
$row = DB_fetchArray($result);
if ($album->access != 3 && !SEC_inGroup($album->mod_group_id) && $row['media_user_id'] != $_USER['uid']) {
COM_errorLog("Someone has tried to illegally sort albums in Media Gallery. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1);
return COM_showMessageText($LANG_MG00['access_denied_msg']);
}
// Build Album List
$album_jumpbox = '<select name="albums" width="40">';
$root_album = new mgAlbum(0);
$root_album->buildJumpBox($album_jumpbox, $album_id);
$album_jumpbox .= '</select>';
// should check the above for errors, etc...
$exif_info = '';
if ($row['media_type'] == 0) {
if (!function_exists('MG_readEXIF')) {
require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
}
$exif_info = MG_readEXIF($row['media_id'], 1, $mqueue);
if (empty($exif_info)) {
$exif_info = '';
}
}
$media_time_month = date("m", $row['media_time']);
$media_time_day = date("d", $row['media_time']);
$media_time_year = date("Y", $row['media_time']);
$media_time_hour = date("H", $row['media_time']);
$media_time_minute = date("i", $row['media_time']);
$month_select = '<select name="media_month">';
$month_select .= COM_getMonthFormOptions($media_time_month);
$month_select .= '</select>';
$day_select = '<select name="media_day">';
for ($i = 1; $i < 32; $i++) {
$day_select .= '<option value="' . $i . '"' . ($media_time_day == $i ? 'selected="selected"' : "") . '>' . $i . '</option>';
}
$day_select .= '</select>';
$current_year = (int) date("Y");
$end_year = $current_year + 10;
$year_select = '<select name="media_year">';
for ($i = 1998; $i < $end_year; $i++) {
$year_select .= '<option value="' . $i . '"' . ($media_time_year == $i ? 'selected="selected"' : "") . '>' . $i . '</option>';
}
$year_select .= '</select>';
$hour_select = '<select name="media_hour">';
for ($i = 0; $i < 24; $i++) {
$hour_select .= '<option value="' . $i . '"' . ($media_time_hour == $i ? 'selected="selected"' : "") . '>' . $i . '</option>';
}
$hour_select .= '</select>';
$minute_select = '<select name="media_minute">';
for ($i = 0; $i < 60; $i++) {
$minute_select .= '<option value="' . $i . '"' . ($media_time_minute == $i ? 'selected="selected"' : "") . '>' . ($i < 10 ? '0' : '') . $i . '</option>';
}
$minute_select .= '</select>';
$media_time = MG_getUserDateTimeFormat($row['media_time']);
$tn_size = 1;
list($thumbnail, $pThumbnail, $size) = Media::getThumbInfo($row, $tn_size);
$attached_thumbnail = '';
if ($row['media_tn_attached'] == 1) {
$atnsize = '';
if ($size != false) {
list($newwidth, $newheight) = Media::getImageWH($size[0], $size[1], 150, 150);
$atnsize = 'width="' . $newwidth . '" height="' . $newheight . '"';
}
$attached_thumbnail = '<img src="' . $thumbnail . '" alt="" ' . $atnsize . XHTML . '>';
$tmpthumb = Media::getDefaultThumbnail($row, $tn_size);
$thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $tmpthumb;
$size = getimagesize($_MG_CONF['path_mediaobjects'] . $tmpthumb);
}
$preview = '';
$preview_end = '';
if ($row['media_type'] == 0 || $row['media_type'] == 1 || $row['media_type'] == 2) {
// image, video and music file
if ($row['media_type'] == 2) {
$win_width = 540;
$win_height = 320;
} elseif ($row['media_type'] == 1) {
$win_width = 660;
$win_height = 525;
} elseif ($row['media_type'] == 0) {
$path = Media::getFilePath('disp', $row['media_filename'], $row['media_mime_ext']);
$media_size_disp = @getimagesize($path);
$win_width = $media_size_disp[0] + 20;
$win_height = $media_size_disp[1] + 20;
} else {
$win_width = 800;
//.........这里部分代码省略.........
示例3: MG_getImageWH_3
function MG_getImageWH_3($imgwidth, $imgheight, $maxwidth, $maxheight, $stretch = true)
{
global $_CONF;
require_once $_CONF['path'] . 'plugins/mediagallery/include/classMedia.php';
return Media::getImageWH($imgwidth, $imgheight, $maxwidth, $maxheight, $stretch);
}