I have the following problem. I can't display the image in the blade template. I use bootstrap and laravel 5.8. I've tried different options (without asset, with / ahead). Folder img in public.
Code blade and html from browser below.
blade
<div class="carousel-item-a intro-item bg-image"
style="background-image: url({{asset('img/slide-1.jpg')}})">
chrome
<div class="carousel-item-a intro-item bg-image"
style="background-image: url(http://127.0.0.1:8000/img/slide-1.jpg)">
Try this. Looks like you should concatenate string with php code.
<div class="carousel-item-a intro-item bg-image"
style="background-image:url('". {{asset('img/slide-1.jpg')}}."')">
Related
Tailwindcss has 2 ways of showing background images:
<div style="background-image: URL();"></div>
<div class="bg-[url('/img/myimage.jpg')]">
This Tailwindcss shows the background image perfectly:
bg-[url('/wp-content/themes/sarasota-soccer-club/images/my-image.jpg')]
but if I try to show an image with an ACF field, it won't work and I have no idea why:
bg-[url(<?php the_field('hero_image'); ?>)] I like this way better because is more elegant. Using style="" in the HTML tag is ugly
but if I use it this way it'll work fine:
style="background-image: url(<?php the_field('hero_image'); ?>);"
So, has anyone found an issue like this with bg-[url(<?php the_field('hero_image'); ?>)]?
I'm working with Laravel 5.8 and in this project I want to show some images that I had uploaded through database like this:
And at the view, I tried this:
<div class="text-center" style="background-image: url('public\images\tavana\{{ $images[0]->path }}');height: 220px;">
But the problem is the image does not load!
However the image already exists at the this directory:
public\images\tavana\imagename.jpg
And other data such as title, subtitle properly shows up.
So how to properly show the image?
use asset to generate url
<div class="text-center" style="background-image: url('{{asset('images/tavana/'.$images[0]->path)}}');height: 220px;background-repeat: no-repeat">
also not sure why you are accessing 0th index $images[0]->path instead you can return first() so it will be $images->path
If you have multiple then use loop
You can't try:
<div class="text-center" style="background-image: url({{url('/')}}.'public/images/tavana/{{ $images[0]->path }}');height: 220px;background-repeat: no-repeat">
i have a laravel project where I need to print a pdf. I made the printing without problems, using a library DOMPDF, but inside the pdf i need to print a content of a Rich Text Area.
The UI:
The output is
Note
<p><b>Test</b></p><p><b><br></b></p><ul><li><b>Test 1</b></li><li><b>Test 2</b></li></ul><p><br></p>
The blade page have:
<div class="row">
<div class="col-xs-12">
<h4>Note</h4>
{{$plan->note}}
</div>
</div>
How can i print the html content correctly?
Basically Laravel does html entity encoding when you print something using {{ $plan->note }}.
In order to not to encode HTML elements, you have to use
{!! $plan->note !!}
This is not only for PDF. It can be used for web page rendering as well.
i'm using Laravel for my application, i want to show a PDF file in view
i know i have to use <embed> or <iframe> but when i use this tags, i can't see my PDF file in my view and it will download automatic, i dont want to download file, just need to see PDF file content.
this is my view :
<div class="row justify-content-center">
<div id="detail_div_a4">
<embed src="{{ $letter->image }}" type="application/pdf" width="100%" height="600px">
</div>
</div>
src return my PDF file location in $letter->image
thank you for your helps <3
As you mentioned, you can use "iframe" to display your pdf. Here is a sample of code that should work for you.
<div class="row justify-content-center">
<iframe src="{{ asset('folder/file_name.pdf') }}" width="50%" height="600">
This browser does not support PDFs. Please download the PDF to view it: Download PDF
</iframe>
</div>
You can play around with the asset declaration to include your variable vs the file path. You can also test this code without your variable to see if that is causing the issue. You may also have some conflicting code in your custom div. Keep in mind you can style the pdf container in the iframe, so you may not need the div labeled "detail_div_a4". Good luck.
Here is another thread that may offer some additional support: HTML embedded PDF iframe
I am using Drupal 8 and i created a page where i display an image and a form inside a block as an inline template.
This looks like this :
<div class="col-md-6" style="padding-right:0px; padding-left:0px;">
<img src="{{ base_path ~ directory }}/sites/default/files/Dinard_S.jpg" id="b-frm-img" style="width: 400px; height:300px;"></div>
Then another div contains my form. What i'm trying to do is to make user with no code knowledge able to change this specific image from the drupal admin.
Is there any way to do this?
I created an admin page to upload an image in a dedicated folder using managed_file type in the form. Seems there is no better ways.