3

I want to display metaimage when i share my link. But i am unable to get image. here is my code. please suggest me what is in my code. Iam new laravel.

<meta property="og:image" content="../storage/uploads/{{$page->meta_image}}">
Amkhan
  • 340
  • 1
  • 3
  • 12

3 Answers3

8
<meta property="og:image" content="{{ url('/path_to_image') }}">

Ref. : https://laravel.com/docs/5.7/helpers

Vipertecpro
  • 3,056
  • 2
  • 24
  • 43
3

For you use storage path :

// (assuming you using storage location)
$path = storage_path();
$path = storage_path($page->meta_image);
<meta property="og:image" content="{{$path}}">

To Get the base Path:

$path = base_path();

To Get Public Path :

$path = public_path();

$path = public_path('css/app.css');

To Get Site URL Path :

$path = url("your_image_path"); // http://example.com/...

Reference : Laravel Path Helper

Bruce
  • 1,647
  • 4
  • 20
  • 22
  • Thank you i solved this by doing this – Amkhan Feb 28 '19 at 08:54
  • 1
    Glad you got the solution to your problem. You can also use the base path like `content="{{ base_path() }}/storage/uploads/{{$page->meta_image}}"` or storage_path like `content="{{ storage_path() }}/uploads/{{$page->meta_image}}"`. – Bruce Feb 28 '19 at 09:03
0

You can use ENV('APP_URL', 'http://localhost') from .env file

James Christian Kaguo
  • 1,251
  • 15
  • 14