I have a carousel showing images. Some of them are thumbs of youtube video in that case i want an image of a play button to be displayed over the thumb image to show that it is a video not a simple image.
<div class="carousel-inner">
#foreach($realisation->images as $key => $img)
#if($img->type == 'image')
<div class="item {{ $key == 0 ? 'active': '' }}">
#if(File::exists($img->image))
<img src="{{asset($img->image)}}" class="image" alt="realisation{{$img->id}}"/>
#endif
</div>
#else
<div class="item {{ $key == 0 ? 'active': '' }}">
<a href="{{$img->video}}" data-lity>
<img src="{{ LaravelVideoEmbed::getYoutubeThumbnail($img->video) }}" class="image" alt="realisation{{$img->id}}">
<img src="{{asset('img/icon-14-orange.png')}}" alt="">
</a>
</div>
#endif
#endforeach
</div>
change your code, add class for play image class="playOverlay":
.....
#else
<div class="item {{ $key == 0 ? 'active': '' }}">
<a href="{{$img->video}}" data-lity>
<img src="{{ LaravelVideoEmbed::getYoutubeThumbnail($img->video) }}" class="image" alt="realisation{{$img->id}}">
<img class="playOverlay" src="{{asset('img/icon-14-orange.png')}}" alt="">
</a>
</div>
#endif
.....
css:
.item{position:relative}
img.playOverlay{
position:absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Related
I'm trying to create a bootstrap carousel album thumbnail.
My code is here...
<div class="col-lg-9 mb-3">
<div id="myCarousel" class="carousel slider d-flex justify-content-center" data-bs-ride="carousel">
<div class="carousel-inner">
#foreach($galleries as $gallery)
<div class="carousel-item {{ $loop->first ? 'active' : '' }}">
<img src="{{ asset('storage/'.$gallery->image) }}" class="img-fluid rounded" alt="{{ $product->title }}">
</div>
#endforeach
</div>
<ol class="carousel-indicators list-inline bottom-12">
#foreach($galleries as $gallery)
<li class="list-inline-item {{ $loop->first ? 'active' : '' }}">
<a id="carousel-selector-{{ $gallery->id }}" class="{{ $loop->first ? 'selected' : '' }}" data-bs-slide-to="{{ $gallery->id }}" data-bs-target="#myCarousel">
<img src="{{ asset('storage/'.$gallery->image) }}" class="img-fluid rounded" alt="{{ $product->title }}">
</a>
</li>
#endforeach
</ol>
</div>
</div>
But when I click on the carousel's indicators, I receive this error from bootstrap.min.js:
Now my question is what is wrong with my code/solution?
I am having two events in my component one is changing the layout and another one is sorting. Changing a layout basically it only replace a layout component inside a parent component. Now when i am calling a sorting then livewire giving me a error 'initialdata is null '.
I am looking for to create a sorting order with this same component. And my code is
<div class="dropdown px-2 d-none d-lg-block">
<div class=" text-dark fw-bold dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="px-1">
<img class="" src="{{ Vite::image('icons/classic.png') }}" alt="" />
</span>
<span>
<img class="" src="{{ Vite::image('icons/filter-down.png') }}" alt="" />
</span>
</div>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item text-primary #if($show == 1)text-primary #else text-dark #endif fw-bolder" href="javascript:void(0)" wire:click="$set('show', '1')">
<img src="{{ Vite::image('icons/compact.png') }}" alt="" class="ps-2" /> Card </a>
<a class="dropdown-item uni-border #if($show == 2)text-primary #else text-dark #endif fw-bolder " href="javascript:void(0)" wire:click="$set('show', '2')">
<img src="{{ Vite::image('icons/classic.png') }}" alt`your text`="" class="ps-2" />Classic </a>
<a class="dropdown-item uni-border #if($show == 3) text-primary #else text-dark #endif fw-bolder" href="javascript:void(0)" wire:click="$set('show', '3')">
<img src="{{ Vite::image('icons/com.png') }}" alt="" class="ps-2" />Compact </a>
</div>
</div>
{{-- sorting option --}}
<div class="d-flex justify-content-between pt-2 align-items-center d-none d-lg-block ">
<div class="d-flex align-items-center justify-content-between">
<div>
<span class="m-0">Selected Filters:</span>
<span class=" mx-3 boat-span2 align-items-center rounded-1">
<span>$500 </span>
<span>
<img src="{{ Vite::image('icons/cross.png') }}" alt="" class="" />
</span>
</span>
<span class=" boat-span2 align-items-center rounded-1">
<span> Skipper </span>
<span>
<img src="{{ Vite::image('icons/cross.png') }}" alt="" class="" />
</span>
</span>
</div>
<div class="">
<h6 class="m-0 text-secondary fw-500 ">
<u> Clear Filters</u>
</h6>
</div>
</div>
</div>
#if($show == 2)
{{-- classic layout --}}
#livewire('frontend.boat.listing.layout.classic',['product' => $product])
#elseif($show == 1)
{{-- card layout --}}
#livewire('frontend.boat.listing.layout.card',['product' => $product])
#elseif($show == 3)
{{-- compact layout --}}
#livewire('frontend.boat.listing.layout.compact',['product' => $product])
#endif
</div>
<?php
namespace App\Http\Livewire\Frontend\Boat\Listing;
use App\Models\Product;
use Livewire\Component;
class Listing extends Component
{
// Mount , boot , hydrate component
public $filter_option_recommend = "recommended";
public $show = "2";
// public $filter_option = "name";
// public $product;
public function detail($id, $title)
{
return redirect()->route('website.boat.detail', [$id, $title]);
}
public function render()
{
$product = Product::join('product_time_assign', 'product_time_assign.product_id', '=', 'products.id')
->where([
'products.type_id' => 1, // boat
'products.status' => 'Active',
])
->select(
'products.id as productid',
'product_time_assign.id as timeassignid',
'products.name',
'products.capacity',
'products.price_starts',
'product_time_assign.skipper',
'product_time_assign.product_time_assign_id',
'products.review_rating',
'products.image',
'products.description',
'products.discount_price'
)
->orderBy($this->filter_option_recommend, 'asc')->get();
return view('livewire.frontend.boat.listing.listing', ['product' => $product]);
}
}
Here is Photo viewer laravel project. it worked well. but I'm having problem about image layout.
This below image is my current photo gallery page. As you can see images are not line. looks not good.
Becase each uploaded photo size are diffrent width and height so this happens I guess.
I'm using Laravel. And this is fancybox.
and I'm using this gentleman's source code.
https://www.itsolutionstuff.com/post/laravel-5-image-gallery-crud-example-from-scratchexample.html
I had been changing below css parameter but I couldn't fix.
Could you teach me code to fix situation please?
CSS of index.blade.php
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- References: https://github.com/fancyapps/fancyBox -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" media="screen">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js"></script>
.gallery
{
display: inline-block;
margin-top: 20px;
}
.form-image-upload{
background: #e8e8e8 none repeat scroll 0 0;
padding: 15px;
}
Image output of Index.blade.php
<div class='list-group gallery'>
#if($images->count())
#foreach($images as $image)
<div class='col-sm-4 col-xs-6 col-md-3 col-lg-3'>
<a class="thumbnail fancybox" rel="ligthbox" href="images/{{ $image->image }}">
<img class="img-responsive" alt="" src="images/{{ $image->image }}" />
<div class='text-center'>
<small class='text-muted'>No.{{ $image->id }}</small>
</div> <!-- text-center / end -->
</a>
</div> <!-- col-6 / end -->
#endforeach
#endif
</div>
Why you don't use Image Width and Height just like this
<img class="img-responsive" alt="" src="images/{{ $image->image }}" height="48" width="48"/> // Here 48 in pixel size
You can add a break line every 4 pictures to make it look cleaner - assuming you are using Bootstrap 4:
#foreach($images as $image)
<div class='col-sm-4 col-xs-6 col-md-3 col-lg-3'>
<a class="thumbnail fancybox" rel="ligthbox" href="images/{{ $image->image }}">
<img class="img-responsive" alt="" src="images/{{ $image->image }}" />
<div class='text-center'>
<small class='text-muted'>No.{{ $image->id }}</small>
</div> <!-- text-center / end -->
</a>
</div> <!-- col-6 / end -->
#if ($image->number % 4 == 0)
<div class="w-100"></div>
#endif
#endforeach
I would like to output posts in order provided by this image (every 3 posts)
here is my blade code:
<section class="blog_area p_120">
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="blog_left_sidebar">
#foreach ($raksti as $raksts)
<article class="blog_style1">
<div class="blog_img">
<img class="img-fluid" src="{{$raksts->image}}" alt="">
</div>
<div class="blog_text">
<div class="blog_text_inner">
<div class="cat">
<a class="cat_btn" href="#">{{$raksts->kato->title}}</a>
<i class="fa fa-calendar" aria-hidden="true"></i> {{$raksts->created_at}}
<i class="fa fa-comments-o" aria-hidden="true"></i> 05
</div>
<a href="#">
<h4>{{$raksts->title}}</h4>
</a>
<p>{{$raksts->short_desc}}</p>
<a class="blog_btn" href="#">Lasīt vairāk</a>
</div>
</div>
</article>
#endforeach
</div>
</div>
</div>
</div>
</section>
For those small blocks the "article" tag have class ="blog_style1 small"
I guess that there need to work with a "for" loop, so can anyone help me to achieve this task and explain a little how that works?
Take a look, you need to tell your code that one image of three has to be wide.
So that you can use modulo:
#foreach ($raksti as $key => $value)
#if($key % 3 = 0)
// set width 100%
#else
// set width 50%
#endif
#endforeach
That makes every third element as 100% wide.
try next code
#foreach ($raksti as $key => $raksts)
//
#if($key % 3 == 1)
// set here style css width 100 %
#else
// set here style css width 50 %
#endif
#endforeach
Laravel has loop variables:
https://laravel.com/docs/5.8/blade#the-loop-variable
You can use $loop->index inside yor foreach and check whether your article must have class small
<article class="blog_style1 #if($loop->index % 3 !== 0) small #endif">
Or you can simply use CSS nth-child
https://css-tricks.com/how-nth-child-works/
Give class small each third element
<section class="blog_area p_120">
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="blog_left_sidebar">
#foreach ($raksti as $key => $raksts)
<article class="blog_style1 {{ ($key % 3 != 0) ? 'small' : '' }}">
<div class="blog_img">
<img class="img-fluid" src="{{$raksts->image}}" alt="">
</div>
<div class="blog_text">
<div class="blog_text_inner">
<div class="cat">
<a class="cat_btn" href="#">{{$raksts->kato->title}}</a>
<i class="fa fa-calendar" aria-hidden="true"></i> {{$raksts->created_at}}
<i class="fa fa-comments-o" aria-hidden="true"></i> 05
</div>
<a href="#">
<h4>{{$raksts->title}}</h4>
</a>
<p>{{$raksts->short_desc}}</p>
<a class="blog_btn" href="#">Lasīt vairāk</a>
</div>
</div>
</article>
#endforeach
</div>
</div>
</div>
</div>
</section>
Hope this helps you
no need to do this in the backend. Use the nth-child functionality of CSS:
.blog_style1{
width: 50%;
}
.blog_style1:nth-child(4n){
width: 100%;
}
Im using dompf trying to generate a pdf and save it to the storage folder and a database, the problem is when i try to generate the pdf, it never load, when i use the sample code in github it work, it shows "test", but when i try to load a view it takes forever. this is the code i'm using
$pdf = PDF::loadView('emails.myView',$myData);
return $pdf->stream();
I have tried using the download and the save methods, but doens't work and the page load forever but the pdf is never generated.
and the view just show 4 or 6 elements with 1 main call $hist, returning the view is rendered without problems.
<style type="text/css">
Bunch of css.
</style>
<table class="center-block">
<tr>
<td colspan="3">
<img src="{{ asset('images/boletin/btn_cabeza.jpg') }}" class="img-responsive center-block">
</td>
</tr>
<tr>
<td rowspan="4" class="aside">
<a href="{{ URL::to('contacto/donaciones') }}">
<img src="{{ asset('images/boletin/btn_dona.jpg') }}" class="img-responsive center-block" >
</a>
<div class="social-container">
<h3>Siguenos en:</h3>
<hr>
<ul>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-youtube-play"></i></li>
</ul>
</div>
<h2 class="text-blue">Historias Epékeinas</h2>
<br>
#if(count($hist->imagenes) > 0)
<img src="{{ asset('images/news/'.$hist->imagenes->first()->image) }}" class="img-responsive img-boletin" alt="{{ $hist->titles->first()->text }}">
#endif
<div class="bg-green padding-20">
<h2 class="boletin-title">
{{ $hist->titles->first()->text }}
#if(!is_null($hist->subtitle))
{{ $hist->subtitle->titles->first()->text }}
#endif
</h2>
</div>
<hr>
<div class="text-justify">
{{ substr(strip_tags($hist->descriptions->first()->text), 0, 1600) }}[...]
<br>
Leer más
</div>
</td>
</tr>
<?php $k = 0;?>
#foreach($article as $a)
#if($k == 0 || $k%2 == 0)
<tr>
#endif
#if(!empty($principal))
#if($a->slugs->first()->text != $principal->id)
<td class="news fixedHeight bg-{{ $colors[$j] }}">
#if(count($a->imagenes) > 0)
<img src="{{ asset('images/news/'.$a->imagenes->first()->image) }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
#else
<img src="{{ asset('images/logo.png') }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
#endif
<h2 class="boletin-title">{{ $a->titles->first()->text }}</h2>
<p class="text-justify">{{ substr(strip_tags($a->descriptions->first()->text), 0, 300) }} [...]</p>
<a target="_blank" href="{{ URL::to('noticias/'.$a->slugs->first()->text) }}" class="btn btn-default btn-xs pull-right">Leer más</a>
<div class="clearfix"></div>
</td>
<?php $k++; ?>
#endif
#else
<td class="news fixedHeight bg-{{ $colors[$j] }}">
#if(count($a->imagenes) > 0)
<img src="{{ asset('images/news/'.$a->imagenes->first()->image) }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
#else
<img src="{{ asset('images/logo.png') }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
#endif
<h2 class="boletin-title">{{ $a->titles->first()->text }}</h2>
<p class="text-justify">{{ substr(strip_tags($a->descriptions->first()->text), 0, 300) }} [...]</p>
<a target="_blank" href="{{ URL::to('noticias/'.$a->slugs->first()->text) }}" class="btn btn-default btn-xs pull-right">Leer más</a>
<div class="clearfix"></div>
</td>
<?php $k++; ?>
#endif
<?php $j++; ?>
#if($j == 4)
<?php $j=0; ?>
#endif
#if(($k != 0 && $k%2 == 0) || $k == count($article))
</tr>
#endif
#endforeach
<tr>
<td colspan="3" class="text-center">
<h3>© Derechos Reservados Funda Epékeina 2016.</h3>
</td>
</tr>
</table>
<div class="container center-block">
<div class="bg-square bg-blue"></div>
<div class="bg-square bg-yellow"></div>
<div class="bg-square bg-green"></div>
<div class="bg-square bg-pink"></div>
</div>
<div class="clearfix"></div>
what could be wrong? is there any other choice for generating pdf.
Check those points in order:
For Laravel 4.* I suggest you to use this DOMPDF wrapper https://github.com/barryvdh/laravel-dompdf/tree/0.4
Maybe your view is trying to render content out of the page, try to add dinamic page break, you can do so by styling an element with page-break-before: always; or page-break-after: always.; Try to delete the foreach and adding 1 or 2 static element rendering it in one page
Check for errors in the view by rendering it in html with return View::make('emails.myView',$myData)->render();.
Check php and html sintax, dompdf doesn't work if some html tags are
not well closed
Consider to use Knp-snappy library for Laravel https://github.com/barryvdh/laravel-snappy/tree/0.1