How I can get content from @yield
in PHP?
Example I have in app.blade.php:
@yield('image-url', asset('/img/metaog.png?2'))
I want getimagesize from image-url:
<?php
$image = getimagesize(yield('image-url', asset('/img/metaog.png?2')));
$width = $image[0];
$height = $image[1];
?>
How I can get this correctly? My code is not working.
In Laravel 5.5 and up:
View::getSection('image-url', 'your default value')
In Laravel 5.4 and below:
View::getSections()['image-url']
That will get what was assigned to that named section. You will have to do your check to see if it has anything still. If using the first method you should be checking if that array key actually exists.
You can use View::hasSection(...)
to check if the section exists at all, if needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With