Welcome Guest, Not a member yet? Register   Sign In
SOLVED - need help with image tag
#1

[eluser]JPrieto[/eluser]
i want to display an image titled mydog.jpg

according to the user guide the htnl helper for this is:

Code:
echo img('../images/mydog.jpg');

... and it works fine.

However, I want to align it to the left, so that text will be right next to the image. The guide does not mention aligning an image -- something very common -- therefore, I come here asking for tips on this issue.

thanks in advance
#2

[eluser]osci[/eluser]
In user_guide it states that
Quote:Additionally, an associative array can be passed to the img() function for complete control over all attributes and values. If an alt attribute is not provided, CodeIgniter will generate an empty string.

So since aligning is a matter of styling you either make a class attribute with the alignment or a style attribute for inline usage.
#3

[eluser]JPrieto[/eluser]
thanks for your reply, it does not make sense to me since it assumes Im an expert in CI and/or PHP.

If I wanted to know how to code so CI displays an image, you would most likely reply by stating ...

"CI has helpers, and one of these helpers, provide an image tag, that will display an image"

by I, on the other hand, would truly help by replying:

1. put the following code in your controller to call up the html helper
Code:
$this->load->helper('html');

2. then in your view page place the following code:

Code:
echo img('images/picture.jpg');

just make sure your url is applicable to your situation

See the difference in explaining things?

Therefore .....

Could you, or anyone else, simply post the code here?

Yes, I did read the guide, but Im confused why it did not provide a sample code for something that is so common. Not putting it down, but rather Im encouraging it to include a very common code straight out.

Im sure it is a simple answer. And a sample code is worth more than a thousand word.

Again, im grateful for your attempt to help out. But, it pretty much does not say anything other than technical stuff im not familiar with (not explained with a sample code)
#4

[eluser]JPrieto[/eluser]
I figured it out:

Code:
$image_properties = array(
                            'src' => '../images/mydog.jpg',
                            'align' => 'right',
                          );

echo img($image_properties);

The guide has an error in that it did not displayed the correct code.

It has a missing "echo" command before the "img($image_properties);"




Theme © iAndrew 2016 - Forum software by © MyBB