CodeIgniter Forums

Full Version: Anchor image using Boostrap
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all!

Through this forum Ive become comfortable with anchors and functions (THANK YOU Blush ) but only with linking text. How do you link an image. I want to use this:


Code:
<a class="navbar-brand" href="#">
   <img src="/docs/4.3/assets/brand/bootstrap-solid.svg" width="30" height="30" alt="">

Heart Heart ,
Mekaboo
Code:
<img src="<?= base_url('/docs/4.3/assets/brand/bootstrap-solid.svg');?>" width="30" height="30" alt=""
@Mekab00,

Here is the documentation link: https://codeigniter.com/user_guide/helpe...url-helper
(05-10-2019, 03:23 AM)InsiteFX Wrote: [ -> ]
Code:
<img src="<?= base_url('/docs/4.3/assets/brand/bootstrap-solid.svg');?>" width="30" height="30" alt=""

Solid, Thank You Heart
(05-10-2019, 06:34 AM)php_rocs Wrote: [ -> ]@Mekab00,

Here is the documentation link: https://codeigniter.com/user_guide/helpe...url-helper

Solid, Thank You as well Heart
(05-10-2019, 03:23 AM)InsiteFX Wrote: [ -> ]
Code:
<img src="<?= base_url('/docs/4.3/assets/brand/bootstrap-solid.svg');?>" width="30" height="30" alt=""
I treid what you gave me and its not working. Im trying to link image with controller/function like this but instead of button it will be an image. I at URL helper info and it seems as if it only links to text not image.
The anchor() function takes 3 arguments.
1. URI string
2. Title
3. Options (optional)

The second argument (title) can be a simple text like 'Click here', but it can also be an image or any other html element.
PHP Code:
$image '<img src="' base_url('assets/images/example.png') . '" width="30" height="30" alt="" />';
echo 
anchor('users/login'$image); 

In this example, the result is an image (example.png) that is clickable, like a normal hyperlink. The link points to the login function in the users controller.
(05-11-2019, 05:18 AM)Wouter60 Wrote: [ -> ]The anchor() function takes 3 arguments.
1. URI string
2. Title
3. Options (optional)

The second argument (title) can be a simple text like 'Click here', but it can also be an image or any other html element.
PHP Code:
$image '<img src="' base_url('assets/images/example.png') . '" width="30" height="30" alt="" />';
echo 
anchor('users/login'$image); 

In this example, the result is an image (example.png) that is clickable, like a normal hyperlink. The link points to the login function in the users controller.

Thank you so very much Heart  I got the img src part but I couldnt link it. Thanks for the help!!