In development, my code generates responsive images in a responsive_images directory. However, in production, it doesn't and does not throw any error as well. Only the original; image gets saved.
My Model. I have striped some code to keep it simple
class Blog extends Model implements HasMedia
{
use HasFactory;
use InteractsWithMedia;
// media library
public function registerMediaCollections(): void
{
$this
->addMediaCollection('blog_main_photo')
->withResponsiveImages();
}
}
My controller method.
public function store()
{
// after creating an article to create an article
$article->addMedia(request()->file('image'))->toMediaCollection('blog_main_photo');
return redirect()->back();
}
I had the same problem however I found my mistake, check if your srcset is https in your production mode. You have to change this in your env file "APP_URL". On your development servers you probably have it set to just http.