Replies: 4 comments 7 replies
-
Need help on this please @freekmurze @crynobone @ArielMejiaDev |
Beta Was this translation helpful? Give feedback.
-
Hi @RVP04 the images could fail to load for a variety of reasons here my suggestion: Instead of setting a public_path like this <div class="page-number"><img src="{{public_path('img/broad-logo.png')}}" width="100" height="20"></div> an absolute path to an external service eg: (s3) could make it work // config/brand.php
[
'brand' => [
'logo' => 'https://aws/my-bucket/images/brand/logo.png'
]
]
// then in your blade component
<div class="page-number"><img src="{{ config('brand.logo') }}" width="100" height="20"></div> This should fix the issue in all environments, remember that locally a relative path should not work and as you could have more than one environment this could lead to a lot of work just to show an image to check environments, etc.... it is easier to direclty load them externally. |
Beta Was this translation helpful? Give feedback.
-
@RVP04 @freekmurze I upload a demo with header and footer images working for relative and absolute paths Videohttps://www.loom.com/share/8912fba845214a1d93aefc99fcf93b93?sid=46351d44-b10f-4830-8841-8cbbd61e1b39 I also make a PR GH-79 to solve this with a package solution, please let me know your feedback |
Beta Was this translation helpful? Give feedback.
-
I have the same issue, could solve it by converting the image URL to base64 first. <header style="width: 100%; display: flex; justify-content: end; padding-right: 1cm;">
@php
$logoUrl = $tenant->logo?->getLargeUrl();
$logo64 = \App\Services\HelperService::imageUrlToBase64($logoUrl);
@endphp
<img style="width: 300px;" src="{{ $logo64 }}" alt="Logo">
</header> Helper function: public static function imageUrlToBase64(string $imageUrl): string {
$imageContents = file_get_contents($imageUrl);
if ($imageContents === false) {
throw new \RuntimeException("Failed to fetch the image from URL: {$imageUrl}");
}
$mimeType = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $imageContents);
$base64 = base64_encode($imageContents);
return "data:{$mimeType};base64,{$base64}";
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
header blade
footer.blade.php
How to reproduce the bug
PDF budlider
asset() helper
orpublic_path()
there is no sign of image in the document. When usealt
attribute it is not showing image not loadedasset()
first page logo not showing (image not loaded it is not coming see the image) and if public path is use just a box appearsasset
public_path
need a solution for this isseues
Package Version
1.1.2
PHP Version
8.3.0
Laravel Version
10.40
Which operating systems does with happen with?
macOS
Notes
No use of #44 discussion
No response
Beta Was this translation helpful? Give feedback.
All reactions