From 6dc277249af1f7b8cf95d1eca888a1768644c163 Mon Sep 17 00:00:00 2001 From: B Vikas Chandra <48272577+vikaschandrab@users.noreply.github.com> Date: Tue, 30 Sep 2025 21:32:59 +0530 Subject: [PATCH] issue fixes --- resources/views/public/blogs/show.blade.php | 63 ++++++++++++--------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/resources/views/public/blogs/show.blade.php b/resources/views/public/blogs/show.blade.php index 2137537..dfd1a3e 100644 --- a/resources/views/public/blogs/show.blade.php +++ b/resources/views/public/blogs/show.blade.php @@ -43,45 +43,48 @@ ]); // Get the absolute URL for images with strict checking + $baseUrl = config('app.url'); $imageUrl = ''; - $defaultLogo = url('/public/meetmytech_logo.jpg'); + $defaultLogo = $baseUrl . '/meetmytech_logo.jpg'; // Function to verify image existence and accessibility - function verifyImage($path) { - if (empty($path)) return false; + function verifyImage($url) { + if (empty($url)) return false; - // For absolute URLs - if (filter_var($path, FILTER_VALIDATE_URL)) { - $headers = @get_headers($path); - return $headers && strpos($headers[0], '200') !== false; - } + // URL encode spaces and special characters + $encodedUrl = str_replace(' ', '%20', $url); - // For storage files - return Storage::disk('public')->exists($path); + // For absolute URLs + $headers = @get_headers($encodedUrl); + return $headers && strpos($headers[0], '200') !== false; } // Check featured image - if ($blog->featured_image && verifyImage($blog->featured_image)) { - $imageUrl = url(Storage::url($blog->featured_image)); - Log::info('Using featured image: ' . $imageUrl); - } - // Check author's profile photo - elseif ($blog->user->profile_photo_path && verifyImage($blog->user->profile_photo_path)) { - $imageUrl = url(Storage::url($blog->user->profile_photo_path)); - Log::info('Using author photo: ' . $imageUrl); + if ($blog->featured_image) { + $featuredImageUrl = url(Storage::url($blog->featured_image)); + // URL encode spaces and special characters + $featuredImageUrl = str_replace(' ', '%20', $featuredImageUrl); + + if (verifyImage($featuredImageUrl)) { + $imageUrl = $featuredImageUrl; + Log::info('Using featured image: ' . $imageUrl); + } } - // Use default logo - else { + + // If featured image fails or doesn't exist, use default logo + if (empty($imageUrl) || !verifyImage($imageUrl)) { $imageUrl = $defaultLogo; Log::info('Using default logo: ' . $imageUrl); } - // Final verification - if (!verifyImage($imageUrl)) { - $imageUrl = $defaultLogo; - Log::info('Fallback to default logo after verification failed'); + // Force HTTPS for production + if (app()->environment('production')) { + $imageUrl = str_replace('http://', 'https://', $imageUrl); } + // Set favicon + $meetMytechFavicon = $baseUrl . '/favicon.ico'; + // Force HTTPS for production if (app()->environment('production') && !str_starts_with($imageUrl, 'https://')) { $imageUrl = str_replace('http://', 'https://', $imageUrl); @@ -98,13 +101,19 @@ function verifyImage($path) { + + + + + + - - + + @@ -174,7 +183,7 @@ function verifyImage($path) { "description": "{{ $blog->description ?: ($blog->excerpt ?: Str::limit(strip_tags($blog->content), 155)) }}", "image": { "@type": "ImageObject", - "url": "{{ $imageUrl }}?v={{ time() }}", + "url": "{{ $meetMytechLogo }}?v={{ time() }}", "width": 1200, "height": 630 },