Support Forums

Image Sizing

This is a discussion on Image Sizing within the Technical Support forums, part of the Technical Support Forums category; Hi, I am trying to size all images under New Listings so that they are the same dimensions. I have ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 01-15-2009, 04:14 PM   #1
Customer
 
Join Date: Aug 2008
Posts: 80
Rep Power: 12
nagrap2 is on a distinguished road
Default Image Sizing

Hi,

I am trying to size all images under New Listings so that they are the same dimensions.

I have a smarty function (I have provided an extract below) to build my output which outputs the "New Tutors" section with photos.

However, if I want to set the height and width of the images to say 100 and 80, then how do I set that? The reason for setting all image dimensions to the same is so that they display neatly.


for ($x = 0; $x<= $loop_count; $x++)
{
//opening tr
$output .= "<tr" . smarty_function_html_table_cycle_newlistings('tr', $tr_attr, $c) . ">\n";
//opening td
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//title
if(defined('SEO'))
{
$listing_title=$loop[$x][title];
$listing_title=str_replace(' ', '_', $listing_title);
$listing_title=preg_replace('/\W/e', '', $listing_title);
$output.="<a href='listing/".$loop[$x][id]."/".$listing_title.".html'>".$loop[$x][title]."</a>";
}
else
{
$output.="<a href='viewlisting.php?view=". $loop[$x][id] ."'>".$loop[$x][title]."</a>";
}
$output.="</td>\n";
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//price
$output.=$loop[$x][price];
$output.="</td>\n";
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//date
//$output.=smarty_modifier_date_format($loop[$x][dateadded], $date_format);
//closing td
$output.="</td>\n";
$output .= "</tr>\n";
}
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline  
Old 01-15-2009, 04:43 PM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,374
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

HTML Images

Keep in mind if you force an image to a fixed size you will almost always compress or stretch the image. It may line up nice and nead put looks MUCH worse than images of slightly different sizes if you ask me.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 01-16-2009, 07:58 AM   #3
Customer
 
Join Date: Aug 2008
Posts: 80
Rep Power: 12
nagrap2 is on a distinguished road
Default

Larry,

I understand the image could look worse, but for now can you advise how I actually make it a fixed size?

Thanks in advance...
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline  
Old 01-16-2009, 08:20 AM   #4
curmudgeon
 
Join Date: Mar 2006
Posts: 5,374
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by nagrap2
Larry,

I understand the image could look worse, but for now can you advise how I actually make it a fixed size?

Thanks in advance...
I just gave you a link to an html tutorial and near the bottom is an example of adjusting the image size.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 01-16-2009, 11:00 AM   #5
Customer
 
Join Date: Aug 2008
Posts: 80
Rep Power: 12
nagrap2 is on a distinguished road
Default

Larry,

The only problem I have is the smarty code I have posted above is alittle confusing to me. I cannot find where the img is created? I see the href tag, but don't know how the img part is being generated. Once I figure that out I can add the height and width attributes.

Any ideas?
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline  
Old 01-16-2009, 11:05 AM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,374
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by nagrap2
Larry,

The only problem I have is the smarty code I have posted above is alittle confusing to me. I cannot find where the img is created? I see the href tag, but don't know how the img part is being generated. Once I figure that out I can add the height and width attributes.

Any ideas?
I dont know every single line of the more than 10,000 lines of code that make up 68C and all you did was post a snippet of code (which is php and not smarty by the way) but didnt say where you got or even exactly specify what section of the page your viewing in reference to the images you want to set the dimensions of.

People here are willing to help but we are not mind readers so your going to have to give us more to go on.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 01-16-2009, 12:40 PM   #7
Customer
 
Join Date: Aug 2008
Posts: 80
Rep Power: 12
nagrap2 is on a distinguished road
Default

Larry,

Sorry for the confusion.

The code is in a function called "new_listings" in the following location:

homepage\includes\classes\smarty\plugins

Code:

function smarty_function_new_listings($params, &$smarty)
{
global $db;

$table_attr = 'border="1"';
$tr_attr = '';
$td_attr = '';
$number=4;
$cols=4;
$rows=3;
$trailpad = ' ';
$vdir = 'down';
$hdir = 'right';
$inner = 'cols';

foreach ($params as $_key=>$_value)
{
switch ($_key)
{
case 'number':
$$_key = (int)$_value;
break;

case 'table_attr':
$$_key = (string)$_value;
break;

case 'tr_attr':
case 'td_attr':
$$_key = $_value;
break;
}
}

$sSQL="SELECT p.id, p.owner, p.title, p.featured, p.section, p.description, p.price, p.dateadded, p.expiration, p.pHighlighted, p.pBold, u.state, u.city, u.country FROM ".PREFIX."listings AS p LEFT JOIN ".PREFIX."users AS u ON p.owner = u.id WHERE p.expiration > NOW() AND p.display = 'Y' ORDER BY p.dateadded DESC LIMIT ".$number;
$result=$db->query($sSQL);
$i=0;
while($row=$result->fetch())
{
$tmp = array(
'id' => $row['id'],
'title'=> $row['title'],
'dateadded'=>$row['dateadded'],
'price'=> FormatCurrency($row['price']),
);
$loop[$i] = $tmp;
$i++;
}
$loop_count = count($loop)-1;

$output = "<table " . $table_attr.">\n";
for ($x = 0; $x<= $loop_count; $x++)
{
//opening tr
$output .= "<tr" . smarty_function_html_table_cycle_newlistings('tr', $tr_attr, $c) . ">\n";
//opening td
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//title
if(defined('SEO'))
{
$listing_title=$loop[$x][title];
$listing_title=str_replace(' ', '_', $listing_title);
$listing_title=preg_replace('/\W/e', '', $listing_title);
$output.="<a href='listing/".$loop[$x][id]."/".$listing_title.".html'>".$loop[$x][title]."</a>";
}
else
{
$output.="<a href='viewlisting.php?view=". $loop[$x][id] ."'>".$loop[$x][title]."</a>";
}
$output.="</td>\n";
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//price
$output.=$loop[$x][price];
$output.="</td>\n";
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//date
//$output.=smarty_modifier_date_format($loop[$x][dateadded], $date_format);
//closing td
$output.="</td>\n";
$output .= "</tr>\n";
}
$output .= "</table>\n";

return $output;
}

function smarty_function_html_table_cycle_newlistings($name , $var, $no)
{
if(!is_array($var))
{
$ret = $var;
}
else
{
$ret = $var[$no % count($var)];
}
return ($ret) ? ' '.$ret : '';
}
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline  
Old 01-16-2009, 01:08 PM   #8
curmudgeon
 
Join Date: Mar 2006
Posts: 5,374
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by nagrap2
Larry,

Sorry for the confusion.

The code is in a function called "new_listings" in the following location:

Have you added a call to the plugin in one of your templates? By default I dont think its actually used. On top of that, that particular plugin doesnt display images, thats why you cant find in the code where to specify there size.

P.S. There really isnt any need to include the contents of the file as long as you tell me what file your looking at.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide image when no image is uploaded? MiśUszatek Modules / Plugins / Modifications 1 09-11-2008 08:37 PM
Thumbnails - sizing problem seymourjames Technical Support 9 07-03-2008 04:38 PM


All times are GMT -4. The time now is 04:23 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0