This question already has an answer here:
How to remove a PATH [closed]
(1 answer)
Closed 2 years ago.
I just got a php script for ebooks.
This is the script https://codecanyon.net/item/ebookshare-ebook-hosting-and-sharing-script/23888795
The problem is that I want to keep the script on one site and the covers/books on another hosting.
The script allows me for the books to put and external URL but not for the covers.
If I try to put the external link in the database, it looks like the script puts a path in front.
How could I remove that path? ( http://localhost/eBook/public/storage/http://mywebsitestorage.com/picture.png )
Thank you
CODE:
images.blade.php
I'm not 100% sure though this is the file I need to change. :(
<div class="base-image">
#if (! $ebook->book_cover->exists)
<div class="image-placeholder">
<i class="fa fa-picture-o"></i>
</div>
#else
<a class="base-image-inner" href="{{ $ebook->book_cover->path }}">
<img src="{{ $ebook->book_cover->path }}" alt="{{ $ebook->name }}">
</a>
#endif
</div>
I'm not sure about it but I think,
<a class="base-image-inner" href="{{ $ebook->book_cover->path }}">
In this section, see other available keys instead of using ->path, Not so sure but maybe you'll find another key
Do this:
You can use explode and then pop the result array
<?php
$string = "http://localhost/eBook/public/storage/http://mywebsitestorage.com/picture.png";
echo getImageNameFromString($string);
function getImageNameFromString($string) {
$explodeString = explode("/", $string);
return array_pop($explodeString);
}
output
picture.png
Related
have the following problem, and is that I need to redirect from a link which is created by me with 6 random characters to make a shortener to a file. The problem is that when I try to access the file I get the url http://127.0.0.1:8000/C:/Users/myUser/Desktop/proyect/public/assets/PDFs/file.pdf but I do not need this url, but the following, which would be from C://.
My doubt is, how could I do this? Since I can't find anything that can solve it and I have been trying for days to find the problem and trying in other ways, even with:
Storage::disk('local')->get($qr->document)
The blade code is as follows:
<a class="button shortlink" href="{{ route('shorten.linkDocument', $qr->code) }}" target="_blank"> <i class="fa fa-link"></i>
{{ route('shorten.linkDocument', $qr->code) }} </a> <br>.
Where it says $qr->code are the 6 random characters generated to act as a shortener and redirector. The route to shorten.linkDocument is found in Web, and is as follows:
Route::get('Pdf/{code}', '\App\Http\Controllers\QrController#shortenLinkDocument')->name('shorten.linkDocument');
The method referenced by the controller is as follows:
public function shortenLinkDocument($code).
{
$find = Qr::where('code', $code)->first();
return redirect($find->document);
}
PS: In $qr->document the absolute path from C:// is stored.
I hope for your help and thank you very much if you have read everything.
Hello and thank you for taking the time to help me with my question. I have a task application which is working great. When you upload images, you can see their thumbnails and even click on them and be directed to a new tab to view the images at 100%. The problem is that when a client uploads a pdf, the icon shows up as a broken image icon. This makes sense as the img tag within the a tag obviously is an image icon.
My question is how can I indicate in my show.blade.php that it is an image when it is an image and a pdf or dox when it is a pdf or doc? Like I said, the app is working so the only code I am concerned with is the following (unless I am mistaken, please let me know):
...
<a data-toggle="" href="/storage/upload/{{ $images[$i]['name'] }}" target="_blank">
<img src="/storage/upload/{{ $images[$i]['name'] }}" class="image-fluid w-50">
</a>
</div>
#endfor
#else
<p class="ml-3 mb-1">No files found</p>
#endif
</div>
I am looking for something like a conditional that says: If img, display the thumb, if not, display an icon that represents "file".
Any help on this would be greatly appreciated. Thank you in advance.
You can simply use a free API to achieve this without writing any code. Use the below link to get your icon as per the extension.
<img src="https://pro.alchemdigital.com/api/extension-image/pdf">
For futher info read this article: Read this Article
To get this to work I changed my above code to the following:
#if (in_array($extension = pathinfo($images[$i]['name'], PATHINFO_EXTENSION), ['jpg', 'png', 'bmp']))
<a data-toggle="" href="/storage/upload/{{ $images[$i]['name'] }}" target="_blank">
<img src="/storage/upload/{{ $images[$i]['name'] }}" class="image-fluid w-50">
</a>
#else
<a data-toggle="" href="/storage/upload/{{ $images[$i]['name'] }}" target="_blank">
<img src="{{ "/icons/{$extension}.jpg" }}" class="image-fluid w-50">
</a>
#endif
</div>
#endfor
#else
<p class="ml-3 mb-1">No images found</p>
#endif
</div>
I then added an icons folder and populated it with the icon images in jpg format. I hope this helps anyone else with the same issue.
i am working on eCommerce project where i got stuck with a issue. i am using url() to generate my url. i have a following code.
<a style="cursor: pointer;" href='{{ url("search?category=$categories[$i]->id")}}' class="menuLinks leftCategoriesProduct"> <span class="catText">{{($categories[$i]->name)}}</span></a>
on click i require
http://localhost/a2z/public/search?category=5
it worked on my one of the blade in the same project but here it generate a different url :
http://localhost/a2z/public/search?category={%22id%22:5,%22name%22:%22All%20Offers%22,%22slug%22:%22all-offers%22,%22user_id%22:2,%22parent_id%22:null,%22deleted%22:0,%22created_at%22:%222017-04-10%2013:21:48%22,%22updated_at%22:%222017-04-10%2013:21:48%22,%22childs%22:[]}-%3Eid
Here it returns the whole object however i need only the category id
I am not sure where i am doing wrong, is there a concatenation problem, or something related to blade which i am missing.
Help will be appreciated, Thanx
code:
{{ url('search') }}?category={{ $categories[$i]->id }}
I think you can try this:
<a style="cursor: pointer;" href="{{ url('search', $categories[$i]->id) }}" class="menuLinks leftCategoriesProduct"> <span class="catText">{{($categories[$i]->name)}}</span></a>
Hope this work for you !!!
<a style="cursor: pointer;" href="{{ url('search?category='.$categories[$i]->id)}}" class="menuLinks leftCategoriesProduct"> <span class="catText">{{($categories[$i]->name)}}</span></a>
I need help as I am trying to create anchor tag in Laravel 5.1
I used this line & this works
{!! Html::link('/dashboard','Dashboard') !!}
But I have code like this
<a href="#" class="logo">
<span class="logo-mini"><b>cpy</b></span>
<span class="logo-lg"><b>Company</b></span>
</a>
I want to fit above code into Laravel 5.1 link format , but i am unable to get it .
Someone help me to sort out this.
You can use URL or route to anchor element.
<a href="{{ URL::to('dashboard')}}" class="logo">
<span class="logo-mini"><b>cpy</b></span>
<span class="logo-lg"><b>Company</b></span>
</a>
This points to /dashboard. If you wish to suffix a parameter for example base-path/dashboard/user-name
then,
<a href="{{ URL::to('dashboard', $username)}}" class="logo">
<span class="logo-mini"><b>cpy</b></span>
<span class="logo-lg"><b>Company</b></span>
</a>
When using URL, makes sure the path is set in routes.php
I am trying to link to a user profile image in Laravels blade template but I am only getting errors here.
This is my image tag containing the link:
<img class="img-circle dashboardprofileimage" src="{{ URL::asset('img/profile_pictures/users/{{ Auth::user()->profile_picture }}') }}"/>
I would be very happy if anyone could help me out here. I guess its a simple thing but I have tried quite a lot of times now.
Thanks.
Your error is using nested {{ }}, you just need it once. Check out the correct code below:
<img
class="img-circle dashboardprofileimage"
src="{{
URL::asset('img/profile_pictures/users/' . Auth::user()->profile_picture)
}}" />
Note: it's splited into several lines for better legibility.
you just use {{ }} one time to print URL::asset() and Auth::user()
<img class="img-circle dashboardprofileimage" src="{{ URL::asset('img/profile_pictures/users/'.Auth::user()->profile_picture) }}"/>