Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Align image with PHP...

Align image with PHP...

Locked

Views: 1,180

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
20 Aug 2006, 8:13 PM
#1
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Align image with PHP...

Is it possible, when using the zen_image function, to align the image within that piece of code?

At the moment my code looks like this...

<?php echo '<a href="' . zen_href_link(FILENAME_NEWS_RSS) . '">' . zen_image($template->get_template_dir(FOOTER_IMAGE_NEWS_RSS, DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . FOOTER_IMAGE_NEWS_RSS, FOOTER_ALT_TEXT_NEWS_RSS) . '</a>'; ?>

I am trying to center the image vertically (valign).

20 Aug 2006, 8:54 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Align image with PHP...

Yes. The zen image function can take up to five parameters. The full list is zen_image(image source, alt_text, width, height, anything else you want). So it's number 5 that's of interest to you. So nothing to stop you using zen_image('....', '....', '', '', 'valign=top') where the '' are two singles quotes and not a double quote.

I'm not entirely sure however that this will achieve the result you want as I thought that valign worked by being applied to a container to determine the alignment of its content, rather than by being applied to the content itself.

20 Aug 2006, 9:14 PM
#3
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Align image with PHP...

Thanks for the info. Just tested it out and it didn't work. :(

I remember having a similar problem like this a while back.

Basically, I have an image (inserted by the zen_image function) and then some text next to it. I need to move the image down by one pixel, or center it vertically.

Maybe pasting the code will help...

<?php echo '<a href="' . zen_href_link(FILENAME_NEWS_RSS) . '">' . zen_image($template->get_template_dir(FOOTER_IMAGE_NEWS_RSS, DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . FOOTER_IMAGE_NEWS_RSS, FOOTER_ALT_TEXT_NEWS_RSS) . '</a>'; ?>  <a href="<?php echo zen_href_link(FILENAME_NEWS_INDEX, '', 'NONSSL'); ?>"><?php echo FOOTER_LINK_NEWS; ?></a>

Not sure how I solved the problem last time.

Any ideas?

20 Aug 2006, 9:24 PM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Align image with PHP...

Personally I wouldn't try to do this through inline styling. I'd pop a class on the A tag and position it through the stylesheet.

If you're intent on using inline styling, then I'd pop in something that is appropriate for positioning an image such as a bit of extra margin-top.

2 Sep 2006, 4:53 PM
#5
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Align image with PHP...

kuroi:

Personally I wouldn't try to do this through inline styling. I'd pop a class on the A tag and position it through the stylesheet.

If you're intent on using inline styling, then I'd pop in something that is appropriate for positioning an image such as a bit of extra margin-top.

After adding some margin-top to the image nothing happened!

I've checked that the class is correctly linked to the image (by adding some padding - which worked).

Also tried adding some padding-top, but again that didn't work.

Any reason for this?

2 Sep 2006, 5:16 PM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Align image with PHP...

Alex Clarke:

After adding some margin-top to the image nothing happened!

I've checked that the class is correctly linked to the image (by adding some padding - which worked).

Also tried adding some padding-top, but again that didn't work.

Any reason for this?What will work depends upon the other elements in proximity to the one you're trying to position, whether they are inline or block elements and the positioning method used on each. There are too many variables to be able answer definitively without seeing the site (that's why my responses to your questions are much more vague than they usually are).

4 Sep 2006, 7:26 AM
#7
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Align image with PHP...

Ok, no problem.

I'll have a look at other elements on the page and see what I can come up with.

When my site finally goes live I'll be sure to post a link to it! :)

Thanks for the help so far.