How to add image to pagination buttons in Code Igniter - php

$config['prev_link']='Previous';
$config['prev_tag_open']='<button type="button" style="border-radius:5px;">';
$config['prev_tag_close']='</button>';
This is the code in the controller. Now, I would like to add an image to this button, how do I do it? if I use an tag with source set to base_url('path/to/file.png') am getting just an empty square with white border around it. any ideas please and thank you?

Put the buttons inside a container (let div) and named with a ID say
<div id="pagin">
<button>1</button>
<button>2</button>
..................
..................
<button>10</button>
</div>
Now just use this bellow script.
<script>
var img = <?= base_url('path/to/file.png'); ?>
$('#pagin button').html('<img src="+img+" alt="image alt text">');
// This will display the image on every button
$('#pagin button:first-child').html('<img src="+img+" alt="image alt text">');
// This will display the image only on the first button
$('#pagin button:last-child').html('<img src="+img+" alt="image alt text">');
// This will display the image only on the last button
$('#pagin button:nth-child(2)').html('<img src="+img+" alt="image alt text">');
// This will display the image only on the 2nd button
</script>

You can do this with CSS like this :
As you are already using inline css you can do this
$config['prev_link']='Previous';
$config['prev_tag_open']='<button type="button" style="border-radius:5px;background-image: url("yourimage.png");">';
$config['prev_tag_close']='</button>';
However i would suggest adding a new class and giving css property to that class.
$config['prev_link']='Previous';
$config['prev_tag_open']='<button type="button" class="pg-prev">';
$config['prev_tag_close']='</button>';
CSS FILE
.pg-prev{
border-radius:5px;
background-image: url("yourimage.png");
}

It's okay, I found a way:
$config['next_link']='Next<img src="'.base_url("/resources/images/next.png").'" width=20; height=20; style="vertical-align: middle; margin-left: 5px;"/>';
This works perfect, thank you guys for your interest.

Related

JQuery hover related information for an image from database based on ID

I have a 'post' row in my database where all the posted posts are stored.
Each post includes an id, image, title, description. I retrieve it to the main page using a while loop and I want to create a hover effect on each image that will display its corresponding information (the title and the description) based on its id.
I tried a few things with jquery but didn't seem to go anywhere.
Basic version of the database row displayed on html:
<img src="http://www.extremetech.com/wp-content/uploads/2012/12/VWXL1-1024-640x426.jpg" class="post" id="1">
<div class="ad_fade" id="fade1"></div>
<img src="http://www.hdwallpaperscool.com/wp-content/uploads/2013/11/peter-pan-cars-sports-car-hd-wallppers-cool-desktop-images.jpg" class="post" id="2">
<div class="ad_fade" id="fade2"></div>
<img src="http://www.hdwallpapers.in/walls/corvette_mallett_concept_car-HD.jpg" class="post" id="3">
<div class="ad_fade" id="fade3"></div>
in the php code I have each img tag have an id setup like so: id="'.$id.'" where $id is a unique id returned from the database
the styling:
.post{
width:100px;
height:100px;
}
.ad_fade{
display:none;
position:absolute;
margin:-105px 0 0;
width:100px;
height:100px;
background:rgba(255,255,255,0.8);
}
http://jsfiddle.net/g45db/
I am trying to create a similar effect as seen on: http://dribbble.com/
It has to hover the related info for that specific image in a dynamic way.
All help is appreciated!
Try it like,
$(function(){
$('img.post').hover(function(){
$(this).next('div').show().html(this.src);
// you can use ajax to get data from database
});
});
Live Demo
Updated try to use mouseleave on div.ad_fade like
$(function () {
$('img.post').hover(function () {
$(this).next('div').show().html($(this).data('title')); // using title here
// you can use ajax to get data from database
});
$('div.ad_fade').on('mouseleave',function(){ // mouse leave for fadeout div
$(this).fadeOut(1000).html('');
});
});
Updated Demo
You either need container to hold title and description on hover of img, create as two separate divs
Try to store information in img tag as data-title and data-description and then apply onmouse over function of jquery to show hover effects
$('img').onmouseover(function(){
var $this = $(this);
var title = $this.data('title');
// try to append title and description in previously created divs
});
The simplest way to display title and description, use title attribute of img tag like below
<img src="http://www.extremetech.com/wp-content/uploads/2012/12/VWXL1-1024-640x426.jpg" class="post" id="1" title="Title and Description">
And if you want to use jquery then use below code. First populate title and description in each for respective image.
<img src="http://www.extremetech.com/wp-content/uploads/2012/12/VWXL1-1024-640x426.jpg" class="post" id="1">
<div class="ad_fade" id="fade1">Title and Description details</div>
$('img').mouseenter(function(){
$(this).next('.ad_fade').show();
});
$('.ad_fade').mouseleave(function(){
$(this).hide();
});

How to draw text on top of image HTML?

I need to draw text in top of the image this the look like
when the page load i need to display price in side the photo.I try it like this
<button class="btn btn-danger" id="buy-btn" data-toggle="modal" data-target=".package-buy-modal">BOOK NOW</button>
<img id="price-tag" style="position: relative;width: 100%; /* for IE 6 */" src="<?php echo base_url()?>assets_profile/img/price.png">
<h2 style="-o-transform: rotate(32deg);-moz-transform: rotate(32deg);-webkit-transform: rotate(32deg);">$<?php echo $car_data['Charges']; ?></h2>
But it didn't work as i expected.how can i do this.if there is another easy way to this ?
Here is an example of using background-image within a div so that you can put more inside the div, ie)text
HTML:
<div id='image' src='http://i.stack.imgur.com/1DZ6X.jpg'>
<h2 id='price'>Price: $10</h2>
</div>
CSS:
#image {
width:243px;
height:163px;
background-image:url('http://i.stack.imgur.com/1DZ6X.jpg');
}
check it out here
Add a z-index value to the <img> and the <h2>. For example, z-index:98 on the <img>, and z-index:99 for the <h2>. (A higher value because you want it on top).
I would also recommend moving all styles to a css file, rather than use the inline style attribute.

Image gallery that scrolls to the image that corresponding to the clicked thumbnail

I am creating a website that has an image gallery.
You have a side menu with the different categories, a hidden div that appears when you click on a category, filled with thumbnails, and when you click on any of the thumbnails it hides the thumbnails div and shows the image gallery in its place.
An example of what I am trying to do is here : http://www.matitacorp.com/web/portfolio.php
What I would like to do is when the thumbnail div hides and the image gallery appears I would also like the image that corresponds to the thumbnail clicked to appear, even if it is 3 or 4 pictures lower in the scrollable thumbnail gallery.
I've tried using .scrolltop() and setting the value but I think that I am missing something. My div's appear properly but I am not getting the scrolltop value to work or I am using the complete wrong function. Hopefully someone can help out.
Here is a piece of the code that I am trying to use:
//thumbnail section
<div id="booth">
<img src="thumb1" alt="" />
<img src="thumb2" alt="" />
<img src="thumb3" alt="" />
</div>
//main image section
<div id="identityOverlay" style="background-image:url(images/bkgrnd_700.gif); height:720px; display:none;">
<div id="imageGallery style="padding-left:95px; padding-top:10px; padding-bottom:15px; overflow:auto; height:610px;">
<img src="mainImg1" /><br />
<img src="mainImg2" /><br />
<img src="mainImg3" /><br />
</div>
</div>
<script>
$("#identityoverlay").click(function () {
$("#identityOverlay").show();
$("#booth").hide();
});
$("#identityoverlayA").click(function () {
var myCont = document.getElementById ("imageGallery");
myCont.scrollTop(100);
$("#identityOverlay").show();
$("#booth").hide();
});
</script>
Thanks!
Well you have couple problems with your code.
First of all you should prevent default action on click and secondly you should hide/show divs first and then scroll to wanted position.
Here is the modified code:
$("#identityoverlayA").click(function (e) {
e.preventDefault;
$("#booth").hide();
$("#identityOverlay").show();
var myCont = document.getElementById ("imageGallery");
myCont.scrollTop(100);
});

JQuery - Cycle multiple images with url

I am rendering with php some amount of images, but also i render the a href="" - the images area changing when they are fading, but the url are the same.
How can I change the url and the image together?
JQuery Cycle
The jquery Cycle plugin can cycle any any elment. So the easy way to do this is to just wrap each image with a hyperlink:
http://jsfiddle.net/lucuma/MV9S5/
<div id="slideshow">
<img src="img1.jpg" />
<img src="img2.jpg" />
<img src="img3.jpg" />
</div>
$('#slideshow').cycle();
Additionally you can use your slide attributes if perhaps you have a title you want updated that is outside of the sliders. You'd use the after event. The following code updates the h1's hyperlink after each slide changes. It sets the text to be the title of the img on the slide. Because my images are wrapped in a hyperlink, I need this line var $cur = $('img', currSlideElement) to get to the img element of the slide.
Demo: http://jsfiddle.net/lucuma/dsK9S/2/
<h1 id="title"></h1>
<div id="slideshow">
<img src="img1.jpg" />
<img src="img2.jpg" />
<img src="img3.jpg" />
</div>
$('#slideshow').cycle({
after:function(currSlideElement, nextSlideElement, options, forwardFlag) {
var $cur = $('img',currSlideElement);
$('#title a').text($cur.attr('title'));
$('#title a').attr('href',$cur.attr('src')).text();
}
});
​
jQuery solution:
$(yourImage).attr('src', 'newImageUrl');
If you are trying to implement a slider. Try nivo.

Inserting my image in PHP

I had a PHP file that properly generates an image that I need. In my main page, there is a link named "View Image". So I put an < a href > tag in the "View Image" so that when it is clicked the image will load. However, when "View Image" was clicked, the whole page will load the image, which is not what I wanted. How will I code it in such a way that it will be just a part my page (e.g. just a small image within the site, not the whole webpage)?
Thanks!
Use an <img> tag to embed the image inside of the page.
<img src="path/to/img.png">
Instead of linking to it.
Try this
//HTML
Show Image
<div id="pre" >
<img src="img.jpg" />
</div>
//Javascript
<script type="text/javascript" >
document.getElementById("pre").style.display="none";
function disp()
{
if(document.getElementById("pre").style.display="none")
{
document.getElementById("pre").style.display="";
}
else
{
document.getElementById("pre").style.display="none";
}
return false;
}
</script>

Categories