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.
Related
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 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')}}."')">
I have an img folder within the public folder of my Laravel 5.4 project. When I refer to the image with the following code.
<img class="mb-3 img-fluid rounded" src="public/img/pdx.jpg" alt="Portland">
I get the broken image icon on the page. I am using Bootstrap 4 cdn for the this page. What am I doing wrong. Any help would be appreciated.
Just remove public from src attribute and then try. Because Laravel only understand assets within public folder
i have different type of users in my application and each user have differerent type of background image for their wall like facebook but here i am confused ho to chang each user background image dynamically as their images name are coming from database and background image class is defined in css file . any solution will be highly appreciated as i am new to laravel and php . thnks
as for laravel blade template engine the code will be like this
#if(isset($data->coverphoto))
<img src="{{asset('$data->coverphoto')}}" title="" />
#elseif(empty($data->coverphoto) || $data->coverphoto == null)
<img src="asset('placeholder.jpg')" title="" />
#endif
first we will check if the data is existing or not then we will place image as a img tag another option is that we will use class like
.coverphoto{
background-image: url('<?= (isset($data->coverphoto))?asset('images/') . $data->coverphoto: asset('images/placeholder.jpg') ?>');
}
<div class="coverphoto"> </div>
I am attempting to create custom field that allows users to login into wordpress dashboard > edit post > upload a pdf > and after publish the post; which will then have a working 'download PDF' button.
I have created the custom field and the option is there to toggle 'PDF' and attach a PDF document. The button appears as it should after publish -- but upon clicking the link doesn't work. Below is my added code that should be working for this functionality. Any suggestions?
<?php $pdf_val = get_custom_field('pdfdoc:get_post','guid');
if($pdf_val){ ?>
<div style="text-align: center;"><button class="downloadBtn" style="color: #ffffff !important;"><span style="color: #fff !important;">Download PDF</span></strong></button></div>
<?php } ?>
Also it is to be noted that within the source, the a tag is actually being populated with the PDF file! But the click doesn't fire? =/
The answer was.. for those who may be interested..
Removing of <button> wrapping the <a> tag.