Image and Thumbnail Display Changes

Discussion in 'Technical Support' started by a68designer, Jul 22, 2008.

Thread Status:
Not open for further replies.
  1. a68designer New Member

    Yep, thats basically it...

    I inserted this piece of code below my description with hopes that it would display the large image:

    <img src="{$smarty.const.URL}/viewimage.php?photo={$image.id}" />

    But it didn't work... Any ideas?
  2. Lhotch curmudgeon

    As I said in my original post that you dismissed, you need to use a path to the image. What you are doing above is passing the images ID number to another script.

    <img src="{$smarty.const.URL}/photos/{$image.image}" />
  3. seymourjames All Hands On Deck

    Forgot to say but if you decide to go with viewlistings2.tpl then this is the key line for you <img src="photos/[[image]]" width="254" height="218" class="image" border="0" alt="[[title]]" />

    You are just calling for a file from a directory called photos which exists at the top level. You will see that if you look at the files on your server.

    If memory serves me correctly you must say that you are using the horizontal listings in your admin control panel to use what i gave you. I think you will find it easier to work with viewlistings2 than viewlistings (the vertical view listings file).
  4. bowers01 Genius At Work

    Hi seymourjames,
    Could i please have a demo of what it looks like? is it running on any of your sites?
    Cheers
  5. a68designer New Member

    Thank you Lhotch and Seymour.

    I am now able to display the large images under my description, I just have to fool with the thumbnail display so that I only have one thumbnail showing rather than having the code loop through and display all of them (assuming someone uploads more than one image).

    Thank you guys very much for your assistance.
  6. Lhotch curmudgeon

    Just remove the original foreach loop that looks like this (assuming still using the template with images down the side).......

    Code:
    {foreach from=$data item=image}
    <p><p><a href="#" onMouseOver="window.status='View Large Image';return true" onMouseOut="window.status='';return true" onClick="window.open('{$smarty.const.URL}/viewimage.php?photo={$image.id}&width={$image.width}&height={$image.height}','_popup','width={$image.width+80},height={$image.height+100},directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no,left=0,top=0,screenx=50,screeny=50');return false"> <img src="thumbs/small_{$image.image}" hspace="5" vspace="5" class="image" border="0" alt="{$image.title}" /></a><br />{$image.title}</p>
    {foreachelse}
    <img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
    {/foreach}
    and replace it with just a sinlge link using the first element of the data array like this....


    Code:
    <p><p><a href="<put your link to anchor below here> <img src="thumbs/small_{$data.0.image}" hspace="5" vspace="5" class="image" border="0" alt="{$data.0.title}" /></a><br />{$image.0.title}</p>
    
  7. a68designer New Member

    That is exactly what I did; I removed that loop (and kept a link to the thumbnails), but then my thumbnails were not appearing at all (just a box with an x)... I did not, however, convert the link to look like ...thumbs/small_{$data.0.image}"

    {$data.0.image} That is the part I could not figure out (the .0.) which I assume tells the link only to grab the 1st thumbnail posted?

    Thank you very very much for your help... I am at work and am unable to test it out right now but I'll be sure to let you know how it works later this afternoon.
  8. Lhotch curmudgeon

    If you append debug=1 to the tail of your URL while viewing an ad you can see all of the variables assigned from the scripts to the template.

    A variable is generally a name and a value. An array is a name but has multiple values, each of them with a name (ie key) and in the case of the images its actually a multidimensional array so there are arrays within in array.

    an eample....

    $data is the name of the array. In it there are 4 more arrays, they werent given names explicity so they were assigned numbers as names (ie keys) and then in each of those there are name (ie key) value pairs.

    {$data} Array (4)
    0 => Array (7)
    id => "4779"
    pid => "1763"
    title => ""
    image => "dsc03846.jpg"
    rank => "5"
    width => 400
    height => 300
    1 => Array (7)
    id => "4780"
    pid => "1763"
    title => ""
    image => "dsc03848.jpg"
    rank => "5"
    width => 400
    height => 300
    2 => Array (7)
    id => "4781"
    pid => "1763"
    title => ""
    image => "dsc03852.jpg"
    rank => "5"
    width => 400
    height => 300
    3 => Array (7)
    id => "4782"
    pid => "1763"
    title => ""
    image => "dsc03855.jpg"
    rank => "5"
    width => 400
    height => 300

    since you just want to display the 1st image we access the array by first using its name which is $data. Then we append the key after that ie $data.0 and then we specify which key within there, ie $data.0.image which is using the above example would output dsc03846.jpg
  9. a68designer New Member

    Lhotch,

    Thank you for your thorough explanation, I am just running into one small anchor error.

    I believe, actually I know, it is with my syntax; here is my code with anchor links in bold.

    Thumbnail Section:
    {if $viewphotos=="Y" && $data <> ''}
    <p><img src="thumbs/small_{$data.0.image}" hspace="5" vspace="5" class="image" border="0" alt="{$data.0.title}" /><br />
    <a href="{$image.0.image}#viewlarge">view larger image</a></p>
    {else}
    <img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
    {/if}

    Large Photo Display Section:
    {if $viewphotos=="Y" && $data <> ''}
    {foreach from=$data item=image}
    <a name="viewlarge"><img src="{$smarty.const.URL}/photos/{$image.image}" /></a>
    {foreachelse}
    <img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
    {/foreach}
    {/if}
  10. Lhotch curmudgeon

    an anchor to another section on the same page just uses the name of an anchor. In the bottom half you have give it a name of "viewlarge" but on the top where you link to it you are using <a href="{$image.0.image}#viewlarge">

    the dollar sign indicates the target is an anchor on the same page and the viewlarge is the name but why do you have {$image.0.image} before the dollar sign?
  11. a68designer New Member

    I tried doing:

    Thumbnail Section:
    {if $viewphotos=="Y" && $data <> ''}
    <p><a href="#viewlarge"><img src="thumbs/small_{$data.0.image}" hspace="5" vspace="5" class="image" border="0" alt="{$data.0.title}" />
    </a>
    </p>
    {else}
    <img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
    {/if}

    Large Photo Display Section:
    {if $viewphotos=="Y" && $data <> ''}
    {foreach from=$data item=image}
    <a name="viewlarge"><img src="{$smarty.const.URL}/photos/{$image.image}" /></a>{foreachelse}
    <img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
    {/foreach}
    {/if}

    But that only takes me to the homepage when I click on the thumbnail rather than to the same page as I've done in the past...
  12. Lhotch curmudgeon

    This may be due to the fact that there are multiple templates that make up the page. Cant say I have ever tried to just us an anchor.

    Keep in mind thought that {$image.0.image} is not a full URL, its just a file name. try.....

    <a href="{$smarty.const.URL}/photos/{$image.image}#viewlarge">view larger image</a></p>
  13. a68designer New Member

  14. Lhotch curmudgeon

    not sure what I was thinking it, that shouldnt work. Thats a link to the photo. You need to try and link to existing page but it has variable data in the URL. Not sure how this would be done, have to think on it.


    try

    <a href="{$smarty.const.URL}/viewlisting.php?view{$lid}#viewlarge">view larger image</a></p>
  15. a68designer New Member

    Even when I tried linking

    <a href="#viewlg">view larger image</a>

    to an anchor that I defined above my large photos as

    <a name="viewlg">Images</a> (so that it can anchor to a title rather than a specific image)

    it still would not work. Anyone else have any suggestions? Lhotch I really appreciate your help thus far, thanks a lot buddy.
Thread Status:
Not open for further replies.

Share This Page