I am trying to display image from its original folder. I want to display the original image in a 1366x768 window.
When I change
<?php $width = 1366;$height = 768; ?>
height in this line, it automaticaly display crop the image in this height and width.
<div class="white_box">
<div class="box-body">
<span class="hide WallHashID"><?php echo $wallpaper->wallpaper_hash; ?></span>
<?php $width = 1366;
$height = 768; ?>
<div class="row">
<div class="col-sm-12">
<div class="wallpaper_image">
<img class="thumbnail img-responsive"
style="width:100%; height:auto; display:block; max-width:<?php echo $width; ?>px;max-height: <?php echo $height; ?>px;"
src="<?php echo $this->image_workshop->crop_image(ORIGINALS_FOLDER_WF . '/' . $wallpaper->wallpaper_image_path, $width, $height, $wallpaper->wallpaper_crop_position, 'thumbnail'); ?>"
alt="<?php echo $wallpaper->wallpaper_name; ?>">
</div>
</div>
</div>
</div>
</div>
<?php } ?>
simply:
<img src="<?php echo base_url(); ?>your folder name /<?php echo $wallpaper->wallpaper_image_path; ?>">
You don't have to use $this->image_workshop->crop_image function, or any other function to process the image. You can use the absolute path of the image and style it with css or with html attributes height and width. For example style it with css:
<img class="thumbnail img-responsive"
style="width:<?php echo $width;?>px; height:<?php echo $height;?>px; display:block; max-width:<?php echo $width; ?>px;max-height: <?php echo $height; ?>px;"
src="<?php echo ORIGINALS_FOLDER_WF . '/' . $wallpaper->wallpaper_image_path ; ?>"
alt="<?php echo $wallpaper->wallpaper_name; ?>">
Or with html tag attributes:
<img class="thumbnail img-responsive"
width="<?php echo $width;?>"
height="<?php echo $height;?>"
src="<?php echo ORIGINALS_FOLDER_WF . '/' . $wallpaper->wallpaper_image_path ; ?>"
alt="<?php echo $wallpaper->wallpaper_name; ?>">
The down side is that you would load the full size image in the browser, where it gets resized. If you care about the information size for the picture, you should create the thumbnails versions as you upload the original. Then use thumbnail version of the image.
Related
i use this template for my image slider "https://www.jssor.com/demos/image-gallery.slider"
i try to change a image if image1 is empty(NULL) to image2, there is my sample code i have try but doesnt work.
<div data-u="slides" style="cursor:default;position:relative;top:0px;left:0px;width:980px;height:550px;overflow:hidden;">
<?php
if (!empty ($upload_dir.$data['image1'])){
?>
<div>
<img data-u="image" src="<?php echo $upload_dir.$data['image1']; ?>" />
<img data-u="thumb" src="<?php echo $upload_dir.$data['image1']; ?>" />
</div>
<?php
}else{
?>
<div>
<img data-u="image" src="<?php echo $upload_dir.$data['image2']; ?>" />
<img data-u="thumb" src="<?php echo $upload_dir.$data['image2']; ?>" />
</div>
<?php
}
?>
this code is work when image1 is able on databases, but when it null the image is not change as image2
It's because your $upload_dir is not empty so $upload_dir.$data['image1'] would not be empty.
Try changing the condition to:
if (!empty($data['image1'])) {
...
}
<?php
$imageDir = "";
$images = glob($imageDir . '*.jpg');
foreach ($images as $image) {
?>
<div class="col-lg-3 col-md-4 col-xs-6">
<?php
$name = chop($image, '.jpg');
$filename = $image;
if (file_exists($filename)) {
$taken = "Screenshot Taken: " . date("F d Y H:i:s", filemtime($filename));
}
?>
<a data-gallery="example-gallery" style="text-decoration:none" href="<?php echo $image; ?>" class="d-block mb-4 h-100" data-toggle="lightbox" data-title="Player Name: <?php echo $name; ?>" data-footer="<?php echo $taken; ?>" data-max-width="800" >
<img class="img-fluid img-thumbnail" src="<?php echo $image; ?>" alt="">
<p><?php echo $name; ?></p>
</a>
</div><?php}?>
Hi . i created a image gallery with php . using glob function. but some images wont display , because those images starts with a #(hash) . EX: www.mysite.com/ss/#insta.jpg
iam using tags . is there any other way to view images like this in a
< img> tag
.
Encode the # in your URL
Replacing it with %23 should work
I am trying to showing cropped images as thubmnails with WideImage.
I made a function with an array of filenames as parameter ($images) where I produce my html
foreach ($images as $img) {
$pathToThumb = str_replace("/upload/images", "/upload/images/thumbs", $img);
$thumb = WideImage::loadFromFile($pathToThumb)->crop('center', 'center', 150, 100)->output('jpg', 100); ?>
<div class="lingerie">
<a class="fancybox" rel="group" href="<?php print $img; ?>">
<img src="<?php echo $thumb; ?>" alt=""/>
</a>
</div>
<?php } ? ?>
For now, all I get is
����JFIF``���u i$�J�$��]5�����j4���%�o�WEʴ���^[7��|��6�d��P$g�bx�e��wh����N��c��rp=Oz��h�F�Z��"��u8q�oN��la_28�g�����1��2G��1^Uy�EJ��'��|��9F[����Vn��2m�j�i��ַߣ,4���? ����2zp3�P[|���>���1���8$u��+cQ��:x���-�II^r1��{U�+O��T�x��*b��3����zv�m �)b�U��j�+'B�`m������a����T��r���Tq�1�*�����{D_s�!AbG;v��������/i5��u�ݶ]�����M�]�]���#$Z���74"+ar]�-�',�B���J��W�}KY�/7H#��7�3-n�=���v�Ps�3�C~��N��h��j�q��6�����- and so on
What is the reason for these weird digits?
I am trying to figure out how to change the photo without the page refreshing. I have seen some of the example but just cannot figure out how to implement it in to my working page.
This is what I have right now:
<div id="propertyDetailsImage">
<img class="image photo" src="<?php echo $property->photos->photo[$mainPhoto - 1]->url; ?>" width="<?php echo $property->mainPhotoWidth * 0.77 ?>" height="<?php echo $property->mainPhotoHeight * 0.77 ?>" alt="<?php echo $property->address->full; ?>"/>
</div>
<div class="photoPosition">
<?php
$previousPhoto = $mainPhoto - 1;
if($previousPhoto == 0) {
$previousPhoto = $property->totalPhotos;
}
$nextPhoto = $mainPhoto + 1;
if ($nextPhoto > $property->totalPhotos) {
$nextPhoto = intval(1);
}
?>
<img src="images/previous.png" alt="Previous photo" height="12" width="13" border="none"/>
<span id="photoPosition"><?php echo $mainPhoto; ?></span> of <?php echo $property>totalPhotos; ?>
<img src="images/next.png" alt="Next photo" height="12" width="13" border="none" />
</div>
</div>
<div class="col-md-6">
<div id="thumbnails">
<h3 class="additional">Photos</h3>
<?php
// Iterate throught the list of photos
foreach($property->photos->photo as $photo) {
?>
<script type="text/javascript">
addPhoto(
<?php echo $photo->id; ?>,
<?php echo $photo->width; ?>,
<?php echo $photo->height; ?>,
"<?php echo $photo->caption; ?>");
</script>
<img src="<?php echo $photo->url; ?>" width="<?php echo $photo->widthSmall; ?>" height="<?php echo $photo->heightSmall; ?>" class="image photo" id="photo<?php echo $photo->position; ?>" alt="Additional Photo of <?php echo $photo->address->advertising; ?>" onclick="return showPhoto(<?php echo $photo->position; ?>)" />
<?php }
?>
Any help is appreciated. Cheers
Dima
You should use ajax to get like this results.
you should go here,
The image slider shown in this demo is for free.
For detailed instructions, please visit online
http://www.menucool.com/slider/javascript-image-slider-demo1
Here is the website I am attempting this on: http://increaseinwebtraffic.com/marywood/deals/
The top few deals are larger than 620 width, but the bottom ones are smaller. I tried to use the code below with no success. I've Googled around and only found permanent solutions.
<?php the_post_thumbnail( array(620,295) ); ?>
Any help is appreciated.
Please try the following code.
<?php
$thumbnail_id = get_post_thumbnail_id(get_the_ID());
if (!empty($thumbnail_id))
{
$thumbnail = wp_get_attachment_image_src($thumbnail_id, 'full');
if (count ($thumbnail) >= 3)
{
$thumbnail_url = $thumbnail[0];
$thumbnail_width = $thumbnail[1];
$thumbnail_height = $thumbnail[2];
$thumbnail_w = 620;
$thumbnail_h = floor($thumbnail_height * $thumbnail_w / $thumbnail_width);
}
}
if (!empty ($thumbnail_url)): ?>
<img class="thumbnail" src="<?php echo $thumbnail_url; ?>" alt="<?php the_title_attribute(); ?>"
width="<?php echo $thumbnail_w; ?>" height="<?php echo $thumbnail_h; ?>" />
<?php endif; ?>
http://www.boxoft.net/2011/10/display-the-wordpress-featured-image-without-stretching-it/
What about putting a around that an setting the above code and then using CSS to set the width and height? Something like this:
CSS
.deals img {
width: 620px;
max-height: 295px;
}
HTML / PHP
<div class="deals"><?php the_post_thumbnail( array(620,295) ); ?></div>