Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FeatureCreepKing's avatar

TipTap with Livewire & Image Uploads or alternatives

Hey :)

I'm wondering who has used TipTap editor with image uploads and Livewire? What's the best way to handle this so it's seamless for the end user? If you don't use TipTap, what do you use and why?

0 likes
2 replies
LaryAI's avatar

Certainly! Here’s a solution for integrating TipTap with Livewire for image uploads, along with some alternatives and reasoning.


Using TipTap with Livewire for Image Uploads

  1. Frontend (TipTap Setup):

    • Use TipTap’s Image extension and override its upload handler.
    • When a user selects an image, use JavaScript to upload the file via AJAX (e.g., using fetch or axios) to a Livewire endpoint.
    • On successful upload, insert the image URL into the editor.
  2. Livewire Component:

    • Create a method to handle the image upload and return the URL.

Example:

Blade View:

<div>
    <div id="editor"></div>
    <input type="hidden" wire:model="content">
</div>

Livewire Component (PHP):

use Livewire\Component;
use Livewire\WithFileUploads;

class Editor extends Component
{
    use WithFileUploads;

    public $content;

    public function uploadImage()
    {
        $this->validate([
            'image' => 'image|max:1024', // 1MB Max
        ]);

        $path = $this->image->store('images', 'public');

        return response()->json(['url' => asset('storage/' . $path)]);
    }

    public function render()
    {
        return view('livewire.editor');
    }
}

JavaScript (TipTap Image Upload Handler):

How it works:

  • The user selects an image in TipTap.
  • The custom upload handler sends the image to a Livewire endpoint.
  • The endpoint stores the image and returns the URL.
  • TipTap inserts the image using the returned URL.

Alternatives:

  • Trix Editor: Has built-in support for file uploads, but less customizable than TipTap.
  • Quill.js: Rich editor with image upload modules available.
  • CKEditor: Powerful, but heavier and more complex to customize.

Why TipTap?

  • Highly customizable and modern.
  • Vue-based, but can be used with Alpine.js or plain JS.
  • Great for advanced use-cases.

Summary:
TipTap with a custom image upload handler (AJAX to Livewire) is a solid approach. If you want a simpler setup, Trix or Quill are good alternatives, but TipTap offers the most flexibility for modern Laravel apps.

Let me know if you need a more detailed code example or help with a specific part!

Please or to participate in this conversation.