Permalink
Browse files

Added option to ignore max image width based on content width

$phpwcms['responsive'] = 1; // 0 old behavior
  • Loading branch information...
slackero committed Nov 18, 2014
1 parent 8909fa0 commit 4dd16a6c75d54c2a70dc1bbf0426c6936b01803a
@@ -188,8 +188,8 @@
$template_default['article']['image_caption_after'] = '';
$template_default['article']['image_div'] = true;
$template_default['article']['image_default_width'] = '200';
$template_default['article']['image_default_height'] = '200';
$template_default['article']['image_default_width'] = '490';
$template_default['article']['image_default_height'] = '370';
$template_default['article']['imagelist_table_class'] = '';
$template_default['article']['imagelist_table_bgcolor'] = '';
@@ -207,13 +207,13 @@
$template_default['article']['imagelist_caption_before'] = '';
$template_default['article']['imagelist_caption_after'] = '';
$template_default['article']['imagelist_default_width'] = 100;
$template_default['article']['imagelist_default_height'] = 100;
$template_default['article']['imagelist_default_width'] = 245;
$template_default['article']['imagelist_default_height'] = 185;
$template_default['imagegallery_default_width'] = 200;
$template_default['imagegallery_default_height'] = 175;
$template_default['imagegallery_default_space'] = 3;
$template_default['imagegallery_default_column'] = 2;
$template_default['imagegallery_default_width'] = 490;
$template_default['imagegallery_default_height'] = 370;
$template_default['imagegallery_default_space'] = 0;
$template_default['imagegallery_default_column'] = 1;
$template_default['article']['keyword_before'] = '<span class="keywords">';
@@ -46,12 +46,13 @@
// content values
$phpwcms['file_maxsize'] = 52428800; // Bytes (50 x 1024 x 1024)
$phpwcms['content_width'] = 538; // max width of the article content column - important for rendering multi column images
$phpwcms['content_width'] = 978; // max width of the article content column - important for rendering multi column images
$phpwcms['img_list_width'] = 100; // max with of the list thumbnail image
$phpwcms['img_list_height'] = 75; // max height of the list thumbnail image
$phpwcms['img_prev_width'] = 538; // max width of the large preview image
$phpwcms['img_prev_height'] = 538; // max height of the large preview image
$phpwcms['img_prev_width'] = 978; // max width of the large preview image
$phpwcms['img_prev_height'] = 734; // max height of the large preview image
$phpwcms['max_time'] = 1800; // logout after max_time/60 seconds
$phpwcms['responsive'] = 1; // 0 max. image width = $phpwcms['content_width'], 1 = as given
// other stuff
$phpwcms['image_library'] = 'GD2'; // GD, GD2, ImageMagick, GraphicsMagick or GM, NetPBM
@@ -670,31 +670,32 @@ function get_article_data($article_id, $limit=0, $sort='', $where='') {
foreach($result as $row) {
$data[$row["article_id"]] = array(
"article_id" => $row["article_id"],
"article_cid" => $row["article_cid"],
"article_title" => $row["article_title"],
"article_subtitle" => $row["article_subtitle"],
"article_keyword" => $row["article_keyword"],
"article_summary" => $row["article_summary"],
"article_redirect" => $row["article_redirect"],
"article_date" => $row["article_date"],
"article_username" => $row["article_username"],
"article_sort" => $row["article_sort"],
"article_notitle" => $row["article_notitle"],
"article_created" => $row["article_created"],
"article_image" => @unserialize($row["article_image"]),
"article_timeout" => $row["article_cache"],
"article_nosearch" => $row["article_nosearch"],
"article_nositemap" => $row["article_nositemap"],
"article_aliasid" => $row["article_aliasid"],
"article_headerdata"=> $row["article_headerdata"],
"article_morelink" => $row["article_morelink"],
"article_begin" => $row["article_begin"],
"article_end" => $row["article_end"],
"article_alias" => $row["article_alias"],
'article_livedate' => $row["article_livedate"],
'article_killdate' => $row["article_killdate"]
);
"article_id" => $row["article_id"],
"article_cid" => $row["article_cid"],
"article_title" => $row["article_title"],
"article_subtitle" => $row["article_subtitle"],
"article_keyword" => $row["article_keyword"],
"article_summary" => $row["article_summary"],
"article_redirect" => $row["article_redirect"],
"article_date" => $row["article_date"],
"article_username" => $row["article_username"],
"article_sort" => $row["article_sort"],
"article_notitle" => $row["article_notitle"],
"article_created" => $row["article_created"],
"article_image" => @unserialize($row["article_image"]),
"article_timeout" => $row["article_cache"],
"article_nosearch" => $row["article_nosearch"],
"article_nositemap" => $row["article_nositemap"],
"article_aliasid" => $row["article_aliasid"],
"article_headerdata"=> $row["article_headerdata"],
"article_morelink" => $row["article_morelink"],
"article_begin" => $row["article_begin"],
"article_end" => $row["article_end"],
"article_alias" => $row["article_alias"],
'article_livedate' => $row["article_livedate"],
'article_killdate' => $row["article_killdate"]
);
// now check for article alias ID
if($row["article_aliasid"]) {
$aid = $row["article_id"];
@@ -260,7 +260,7 @@
$article['image']['zoom'] = empty($_POST["cimage_zoom"]) ? 0 : 1;
$article['image']['lightbox'] = empty($_POST["cimage_lightbox"]) ? 0 : 1;
if ($article['image']['width'] > $phpwcms["content_width"] || $article['image']['width'] == '') {
if ((!RESPONSIVE_MODE && $article['image']['width'] > $phpwcms["content_width"]) || $article['image']['width'] == '') {
$article['image']['width'] = $phpwcms["content_width"];
}
@@ -294,7 +294,7 @@
$article['image']['list_maxwords'] = empty($_POST["article_listmaxwords"]) ? 0 : intval($_POST["article_listmaxwords"]);
if($article['image']['list_width'] > $phpwcms["content_width"] || $article['image']['list_width'] == '') {
if((!RESPONSIVE_MODE && $article['image']['list_width'] > $phpwcms["content_width"]) || $article['image']['list_width'] == '') {
$article['image']['list_width'] = $phpwcms["content_width"];
}
@@ -36,13 +36,15 @@
$content["image_width"] = (intval($_POST["cimage_width"])) ? intval($_POST["cimage_width"]) : "";
$content["image_height"] = (intval($_POST["cimage_height"])) ? intval($_POST["cimage_height"]): "";
$temp_img_maxwidth = ($content["image_pos"] == 6 || $content["image_pos"] == 7) ? intval($phpwcms["content_width"] / 1.75) : $phpwcms["content_width"];
if (($content["image_width"] > $temp_img_maxwidth) || ($content["image_width"] == "")) $content["image_width"] = $temp_img_maxwidth;
if((!RESPONSIVE_MODE && $content["image_width"] > $temp_img_maxwidth) || ($content["image_width"] == "")) {
$content["image_width"] = $temp_img_maxwidth;
}
// check for image information and get alle infos from file
$img_sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_file WHERE f_id=" . $content["image_id"] . " LIMIT 1;";
if ($img_result = mysql_query($img_sql, $db) or die("error while getting content image info")) {
if ($img_row = mysql_fetch_assoc($img_result)) {
// new structure of image information
// dbid:filename:hash:extension:width:height:caption:position:zoom
$content["image_info"] = $img_row['f_id'];
@@ -49,12 +49,12 @@
// remove form tag from form template
$content["ecard"]["form"] = preg_replace("'<form[^>]*?>(.*?)</form>'si", '$1', $content["ecard"]["form"]);
if(is_array($content["ecard"]["list"]) && count($content["ecard"]["list"])) {
$img_sql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE (";
$img_sort = array();
foreach($content["ecard"]["list"] as $key => $value) {
if ($imgx) $img_sql .= " OR ";
$img_sql .= "f_id=" . intval($value);
@@ -64,26 +64,26 @@
$img_sql .= "0";
}
$img_sql .= ");";
// check for image information and get alle infos from file
if ($img_result = mysql_query($img_sql, $db) or die("error while getting content image only info")) {
// Gegenrechnen von Breite zu Anzahl Spalten und Bildabstand
$temp_count_img = mysql_num_rows($img_result);
if($content["ecard"]["col"] > $temp_count_img) $content["ecard"]["col"] = $temp_count_img;
$temp_img_maxwidth = $phpwcms["content_width"] - (($content["ecard"]["col"] - 1) * $content["ecard"]["space"]);
$temp_img_maxwidth = intval($temp_img_maxwidth / $content["ecard"]["col"]);
if (($content["ecard"]["width"] > $temp_img_maxwidth) || ($content["ecard"]["width"] == "")) {
if ((!RESPONSIVE_MODE && $content["ecard"]["width"] > $temp_img_maxwidth) || ($content["ecard"]["width"] == "")) {
$content["ecard"]["width"] = $temp_img_maxwidth;
$temp_width = $content["ecard"]["width"];
}
$imgx = 0;
$current_img_key = 0;
while ($img_row = mysql_fetch_assoc($img_result)) {
// set correct sorting
foreach($content["ecard"]["list"] as $key => $value) {
if($value == $img_row['f_id']) {
@@ -99,9 +99,9 @@
$content['ecard']['images'][$current_img_key][4] = $temp_width;
$content['ecard']['images'][$current_img_key][5] = $temp_height;
$content['ecard']['images'][$current_img_key][6] = isset($content["ecard"]["image_cctext"][$current_img_key]) ? trim($content["ecard"]["image_cctext"][$current_img_key]) : '';
$imgx++;
}
mysql_free_result($img_result);
ksort($content['ecard']['images']);
@@ -42,15 +42,15 @@
$imgx = 0;
if (is_array($content["image_list"]) && sizeof($content["image_list"])) {
// zuweisen der passenden ImageID und Neuvergabe des Arrays
$img_sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_file WHERE (";
$img_sort = array();
foreach($content["image_list"] as $key => $value) {
if ($imgx) $img_sql .= " OR ";
$img_sql .= "f_id=" . intval($value);
$imgx++;
$imgx++;
}
if(!$imgx) {
$img_sql .= "0";
@@ -59,46 +59,50 @@
// check for image information and get alle infos from file
if ($img_result = mysql_query($img_sql, $db) or die("error while getting content image only info")) {
// Gegenrechnen von Breite zu Anzahl Spalten und Bildabstand
//$temp_count_img = mysql_num_rows($img_result);
$temp_count_img = $imgx;
$content["image_col"] = ($content["image_col"] > $temp_count_img) ? $temp_count_img : $content["image_col"];
$temp_img_maxwidth = $phpwcms["content_width"] - (($content["image_col"] - 1) * $content["image_space"]);
$temp_img_maxwidth = ($content["image_pos"] == 6 || $content["image_pos"] == 7) ? intval($temp_img_maxwidth / 1.75) : $temp_img_maxwidth;
$temp_img_maxwidth = intval($temp_img_maxwidth / $content["image_col"]);
if (($content["image_width"] > $temp_img_maxwidth) || ($content["image_width"] == "")) {
$content["image_width"] = $temp_img_maxwidth;
if(RESPONSIVE_MODE) {
$temp_width = $content["image_width"];
} else {
$temp_img_maxwidth = $phpwcms["content_width"] - (($content["image_col"] - 1) * $content["image_space"]);
$temp_img_maxwidth = ($content["image_pos"] == 6 || $content["image_pos"] == 7) ? intval($temp_img_maxwidth / 1.75) : $temp_img_maxwidth;
$temp_img_maxwidth = intval($temp_img_maxwidth / $content["image_col"]);
if ($content["image_width"] > $temp_img_maxwidth || $content["image_width"] == "") {
$content["image_width"] = $temp_img_maxwidth;
$temp_width = $content["image_width"];
}
}
$imgx = 0;
// try to handle multiple same image IDs
$temp_img_row = array();
while ($img_row = mysql_fetch_assoc($img_result)) {
$temp_img_row[$img_row['f_id']] = $img_row;
}
mysql_free_result($img_result);
foreach($content["image_list"] as $key => $value) {
if(isset($temp_img_row[$value])) {
$content['tmp_images'][$key][0] = $temp_img_row[$value]['f_id'];
$content['tmp_images'][$key][1] = $temp_img_row[$value]['f_name'];
$content['tmp_images'][$key][2] = $temp_img_row[$value]['f_hash'];
$content['tmp_images'][$key][3] = $temp_img_row[$value]['f_ext'];
$content['tmp_images'][$key][4] = $temp_width;
$content['tmp_images'][$key][5] = $temp_height;
$content['tmp_images'][$key][6] = isset($content["image_cctext"][$key]) ? trim($content["image_cctext"][$key]) : '';
}
}
}
}
}
@@ -34,13 +34,15 @@
$content["image_width"] = (intval($_POST["cimage_width"])) ? intval($_POST["cimage_width"]) : "";
$content["image_height"] = (intval($_POST["cimage_height"])) ? intval($_POST["cimage_height"]): "";
$temp_img_maxwidth = ($content["image_pos"] == 6 || $content["image_pos"] == 7) ? intval($phpwcms["content_width"] / 1.75) : $phpwcms["content_width"];
if (($content["image_width"] > $temp_img_maxwidth) || ($content["image_width"] == "")) $content["image_width"] = $temp_img_maxwidth;
if ((!RESPONSIVE_MODE && $content["image_width"] > $temp_img_maxwidth) || ($content["image_width"] == "")) {
$content["image_width"] = $temp_img_maxwidth;
}
// check for image information and get alle infos from file
$img_sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_file WHERE f_id=" . $content["image_id"] . " LIMIT 1;";
if ($img_result = mysql_query($img_sql, $db) or die("error while getting content image info")) {
if ($img_row = mysql_fetch_assoc($img_result)) {
// new structure of image information
// dbid:filename:hash:extension:width:height:caption:position:zoom
$content["image_info"] = $img_row['f_id'];
@@ -41,10 +41,10 @@
if (is_array($content['reference']["list"]) && count($content['reference']["list"])) {
$img_sql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE (";
$imgx = 0;
foreach($content['reference']["list"] as $key => $value) {
unset ($content['reference']["list"][$key]);
$content['reference']["list"][$key]['img_id'] = intval($value);
@@ -59,17 +59,17 @@
// count images
$content['reference']["col"] = mysql_num_rows($img_result);
if ($content['reference']["width"] > $phpwcms["content_width"] || $content['reference']["width"] == '') {
if((!RESPONSIVE_MODE && $content['reference']["width"] > $phpwcms["content_width"]) || $content['reference']["width"] == '') {
$content['reference']["width"] = $phpwcms["content_width"];
}
$temp_width = $content['reference']["width"] - (2 * $content['reference']["border"]);
$temp_height = $content['reference']["height"] - (2 * $content['reference']["border"]);
while ($img_row = mysql_fetch_assoc($img_result)) {
foreach($content['reference']["list"] as $key => $value) {
if ($content['reference']["list"][$key]['img_id'] == $img_row['f_id']) {
$content['reference']["list"][$key][0] = $img_row['f_id'];
$content['reference']["list"][$key][1] = $img_row['f_name'];
$content['reference']["list"][$key][2] = $img_row['f_hash'];
@@ -81,7 +81,7 @@
}
}
}
// check if more than 1 reference image available
$temp_list_count = count($content['reference']["list"]);
if($temp_list_count > 1) {
@@ -92,7 +92,7 @@
if(!$content['reference']["blockheight"]) {
$content['reference']["blockheight"] = $phpwcms["img_prev_height"];
}
$content['reference']['showlist'] = 1;
// alignment: 0 = horizontal
@@ -107,20 +107,20 @@
if($temp_list_width <= 0) $temp_list_width = 10;
$content['reference']["temp_list_width"] = $temp_list_width;
$content['reference']["temp_list_height"] = '';
} else {
$temp_list_height = $content['reference']["blockheight"] - (($temp_list_count - 1) * $content['reference']["space"]);
$temp_list_height = $temp_list_height / $temp_list_count;
$temp_list_height = $temp_list_height - (2 * $content['reference']["listborder"]);
$temp_list_height = intval($temp_list_height);
if($temp_list_height <= 0) $temp_list_height = 10;
$content['reference']["temp_list_height"] = $temp_list_height;
$content['reference']["temp_list_width"] = '';
}
}
}
Oops, something went wrong.

1 comment on commit 4dd16a6

@jensensen

This comment has been minimized.

Show comment
Hide comment
@jensensen

jensensen Nov 19, 2014

Wow, thank you! I haven't tried yet, but I think that THIS change was long awaited. It would be a very big and a very important step forward for a better, seamless integration, of the bootstrap CSS framework. Now the development of responsive projects on the web, created with phpwcms will be much easier.

jensensen commented on 4dd16a6 Nov 19, 2014

Wow, thank you! I haven't tried yet, but I think that THIS change was long awaited. It would be a very big and a very important step forward for a better, seamless integration, of the bootstrap CSS framework. Now the development of responsive projects on the web, created with phpwcms will be much easier.

Please sign in to comment.