├── .editorconfig ├── .gitignore ├── README.md ├── composer.json ├── composer.lock └── src ├── TinymceController.php ├── TinymceServiceProvider.php ├── helpers.php ├── routes.php └── views ├── example.blade.php └── upload_form.blade.php /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-tinymce-simple-imageupload 2 | 3 | The simple image upload for TinyMCE in Laravel. 4 | 5 | ## Why made this? 6 | 7 | Because, I use TinyMCE and basically, it is pretty hard to understand how to upload images directly to the editor while editing content. There are many TinyMCE image uploaders out there, but they are too complicated in functions, and I only need one core use-case, **pick up an image to upload**. 8 | 9 | That's it, so I create this package for my projects to re-use. Well, if you want, you can use this too. 10 | 11 | **This package works with Laravel 5.0+.** 12 | 13 | 14 | ## Installation 15 | 16 | For Laravel 5.5+: 17 | 18 | ``` 19 | $ composer require "petehouston/laravel-tinymce-simple-imageupload:~1.3" 20 | ``` 21 | 22 | For Laravel before 5.5: 23 | 24 | ``` 25 | $ composer require "petehouston/laravel-tinymce-simple-imageupload:~1.1" 26 | ``` 27 | 28 | For laravel version 5.4 and older, you need to register the service provider in `config/app.php`. 29 | 30 | ``` 31 | 'providers' => [ 32 | ... 33 | 34 | Petehouston\Tinymce\TinymceServiceProvider::class, 35 | 36 | ] 37 | ``` 38 | 39 | ## Usage 40 | 41 | In the view that contain setup for TinyMCE, you need to include the upload view, add this line at the bottom, 42 | 43 | ``` 44 | @include('mceImageUpload::upload_form') 45 | ``` 46 | 47 | Don't worry, this form is hidden from your view, no-one will see it because it is `display: none`. 48 | 49 | Next step is to add this config to the `tinymce` object, 50 | 51 | ``` 52 | tinymce.init({ 53 | // .. your config here 54 | relative_urls: false, 55 | file_browser_callback: function(field_name, url, type, win) { 56 | // trigger file upload form 57 | if (type == 'image') $('#formUpload input').click(); 58 | } 59 | }); 60 | ``` 61 | 62 | That's all, now you should be able to upload image directly to the editor while writing content. 63 | 64 | **You can publish view in case you need to customize in `resources/views` directory** 65 | 66 | ``` 67 | $ php artisan vendor:publish --provider=Petehouston\Tinymce\TinymceServiceProvider 68 | ``` 69 | 70 | ### Try example 71 | 72 | There is a setup example in the package, you can try in your project by adding a sample route, 73 | 74 | ``` 75 | Route::get('/tinymce_example', function () { 76 | return view('mceImageUpload::example'); 77 | }); 78 | ``` 79 | 80 | ### Some notes 81 | 82 | **The image upload handler** 83 | 84 | I setup already a controller [`Petehouston\Tinymce\TinymceController`](https://github.com/petehouston/laravel-tinymce-simple-imageupload/blob/master/src/TinymceController.php) which implements a method for image uploading. 85 | 86 | As you can see it will store all uploaded images in `public/img` directory, the name is like a concatenated hash, 87 | 88 | ``` 89 | $filename = 'image_'.time().'_'.$image->hashName(); 90 | ``` 91 | 92 | The default route for handling image upload is `/tinymce/simple-image-upload`. 93 | 94 | **Customize upload url and controller** 95 | 96 | If you don't want to pre-config of the package, make yours. 97 | 98 | While including the uploading form, pass in the url of handling post image upload 99 | 100 | ``` 101 | @include('mceImageUpload::upload_form', ['upload_url' => 'YOUR_URL_FOR_HANDLING_IMAGE_UPLOAD']) 102 | ``` 103 | 104 | Add a method for handling image upload that **should return the same result** as in [`Petehouston\Tinymce\TinymceController`](https://github.com/petehouston/laravel-tinymce-simple-imageupload/blob/master/src/TinymceController.php). 105 | 106 | 107 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "petehouston/laravel-tinymce-simple-imageupload", 3 | "description": "Simple image upload for TinyMCE in Laravel.", 4 | "version": "1.3.1", 5 | "type": "library", 6 | "license": "MIT", 7 | "keywords": [ 8 | "laravel", 9 | "laravel 5", 10 | "laravel 7", 11 | "laravel 8", 12 | "tinymce", 13 | "image upload", 14 | "php" 15 | ], 16 | "homepage": "https://github.com/petehouston/laravel-tinymce-simple-imageupload", 17 | "authors": [ 18 | { 19 | "name": "Pete Houston", 20 | "email": "contact@petehouston.com", 21 | "homepage": "http://petehouston.com" 22 | } 23 | ], 24 | "require": { 25 | "illuminate/support": "~5.1|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0", 26 | "php": "~5.5|~5.6|7.*|8.*" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "Petehouston\\Tinymce\\": "src" 31 | } 32 | }, 33 | "extra": { 34 | "laravel": { 35 | "providers": [ 36 | "Petehouston\\Tinymce\\TinymceServiceProvider" 37 | ] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "027ff972ae9e4d091ad652491db0f38f", 8 | "packages": [ 9 | { 10 | "name": "doctrine/inflector", 11 | "version": "v1.3.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/doctrine/inflector.git", 15 | "reference": "5527a48b7313d15261292c149e55e26eae771b0a" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", 20 | "reference": "5527a48b7313d15261292c149e55e26eae771b0a", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": "^7.1" 25 | }, 26 | "require-dev": { 27 | "phpunit/phpunit": "^6.2" 28 | }, 29 | "type": "library", 30 | "extra": { 31 | "branch-alias": { 32 | "dev-master": "1.3.x-dev" 33 | } 34 | }, 35 | "autoload": { 36 | "psr-4": { 37 | "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" 38 | } 39 | }, 40 | "notification-url": "https://packagist.org/downloads/", 41 | "license": [ 42 | "MIT" 43 | ], 44 | "authors": [ 45 | { 46 | "name": "Roman Borschel", 47 | "email": "roman@code-factory.org" 48 | }, 49 | { 50 | "name": "Benjamin Eberlei", 51 | "email": "kontakt@beberlei.de" 52 | }, 53 | { 54 | "name": "Guilherme Blanco", 55 | "email": "guilhermeblanco@gmail.com" 56 | }, 57 | { 58 | "name": "Jonathan Wage", 59 | "email": "jonwage@gmail.com" 60 | }, 61 | { 62 | "name": "Johannes Schmitt", 63 | "email": "schmittjoh@gmail.com" 64 | } 65 | ], 66 | "description": "Common String Manipulations with regard to casing and singular/plural rules.", 67 | "homepage": "http://www.doctrine-project.org", 68 | "keywords": [ 69 | "inflection", 70 | "pluralize", 71 | "singularize", 72 | "string" 73 | ], 74 | "time": "2018-01-09T20:05:19+00:00" 75 | }, 76 | { 77 | "name": "illuminate/contracts", 78 | "version": "v6.0.4", 79 | "source": { 80 | "type": "git", 81 | "url": "https://github.com/illuminate/contracts.git", 82 | "reference": "403b24e356346c1cd13ad794d87ec7c57a5363bb" 83 | }, 84 | "dist": { 85 | "type": "zip", 86 | "url": "https://api.github.com/repos/illuminate/contracts/zipball/403b24e356346c1cd13ad794d87ec7c57a5363bb", 87 | "reference": "403b24e356346c1cd13ad794d87ec7c57a5363bb", 88 | "shasum": "" 89 | }, 90 | "require": { 91 | "php": "^7.2", 92 | "psr/container": "^1.0", 93 | "psr/simple-cache": "^1.0" 94 | }, 95 | "type": "library", 96 | "extra": { 97 | "branch-alias": { 98 | "dev-master": "6.0-dev" 99 | } 100 | }, 101 | "autoload": { 102 | "psr-4": { 103 | "Illuminate\\Contracts\\": "" 104 | } 105 | }, 106 | "notification-url": "https://packagist.org/downloads/", 107 | "license": [ 108 | "MIT" 109 | ], 110 | "authors": [ 111 | { 112 | "name": "Taylor Otwell", 113 | "email": "taylor@laravel.com" 114 | } 115 | ], 116 | "description": "The Illuminate Contracts package.", 117 | "homepage": "https://laravel.com", 118 | "time": "2019-09-18T12:32:21+00:00" 119 | }, 120 | { 121 | "name": "illuminate/support", 122 | "version": "v6.0.4", 123 | "source": { 124 | "type": "git", 125 | "url": "https://github.com/illuminate/support.git", 126 | "reference": "b132b6cc61df520a4d8fc3ffec01e8b3ff4e8202" 127 | }, 128 | "dist": { 129 | "type": "zip", 130 | "url": "https://api.github.com/repos/illuminate/support/zipball/b132b6cc61df520a4d8fc3ffec01e8b3ff4e8202", 131 | "reference": "b132b6cc61df520a4d8fc3ffec01e8b3ff4e8202", 132 | "shasum": "" 133 | }, 134 | "require": { 135 | "doctrine/inflector": "^1.1", 136 | "ext-json": "*", 137 | "ext-mbstring": "*", 138 | "illuminate/contracts": "^6.0", 139 | "nesbot/carbon": "^2.0", 140 | "php": "^7.2" 141 | }, 142 | "conflict": { 143 | "tightenco/collect": "<5.5.33" 144 | }, 145 | "suggest": { 146 | "illuminate/filesystem": "Required to use the composer class (^6.0).", 147 | "moontoast/math": "Required to use ordered UUIDs (^1.1).", 148 | "ramsey/uuid": "Required to use Str::uuid() (^3.7).", 149 | "symfony/process": "Required to use the composer class (^4.3.4).", 150 | "symfony/var-dumper": "Required to use the dd function (^4.3.4).", 151 | "vlucas/phpdotenv": "Required to use the Env class and env helper (^3.3)." 152 | }, 153 | "type": "library", 154 | "extra": { 155 | "branch-alias": { 156 | "dev-master": "6.0-dev" 157 | } 158 | }, 159 | "autoload": { 160 | "psr-4": { 161 | "Illuminate\\Support\\": "" 162 | }, 163 | "files": [ 164 | "helpers.php" 165 | ] 166 | }, 167 | "notification-url": "https://packagist.org/downloads/", 168 | "license": [ 169 | "MIT" 170 | ], 171 | "authors": [ 172 | { 173 | "name": "Taylor Otwell", 174 | "email": "taylor@laravel.com" 175 | } 176 | ], 177 | "description": "The Illuminate Support package.", 178 | "homepage": "https://laravel.com", 179 | "time": "2019-09-18T12:32:21+00:00" 180 | }, 181 | { 182 | "name": "nesbot/carbon", 183 | "version": "2.24.0", 184 | "source": { 185 | "type": "git", 186 | "url": "https://github.com/briannesbitt/Carbon.git", 187 | "reference": "934459c5ac0658bc765ad1e53512c7c77adcac29" 188 | }, 189 | "dist": { 190 | "type": "zip", 191 | "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/934459c5ac0658bc765ad1e53512c7c77adcac29", 192 | "reference": "934459c5ac0658bc765ad1e53512c7c77adcac29", 193 | "shasum": "" 194 | }, 195 | "require": { 196 | "ext-json": "*", 197 | "php": "^7.1.8 || ^8.0", 198 | "symfony/translation": "^3.4 || ^4.0" 199 | }, 200 | "require-dev": { 201 | "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", 202 | "kylekatarnls/multi-tester": "^1.1", 203 | "phpmd/phpmd": "dev-php-7.1-compatibility", 204 | "phpstan/phpstan": "^0.11", 205 | "phpunit/phpunit": "^7.5 || ^8.0", 206 | "squizlabs/php_codesniffer": "^3.4" 207 | }, 208 | "bin": [ 209 | "bin/carbon" 210 | ], 211 | "type": "library", 212 | "extra": { 213 | "laravel": { 214 | "providers": [ 215 | "Carbon\\Laravel\\ServiceProvider" 216 | ] 217 | } 218 | }, 219 | "autoload": { 220 | "psr-4": { 221 | "Carbon\\": "src/Carbon/" 222 | } 223 | }, 224 | "notification-url": "https://packagist.org/downloads/", 225 | "license": [ 226 | "MIT" 227 | ], 228 | "authors": [ 229 | { 230 | "name": "Brian Nesbitt", 231 | "email": "brian@nesbot.com", 232 | "homepage": "http://nesbot.com" 233 | }, 234 | { 235 | "name": "kylekatarnls", 236 | "homepage": "http://github.com/kylekatarnls" 237 | } 238 | ], 239 | "description": "A API extension for DateTime that supports 281 different languages.", 240 | "homepage": "http://carbon.nesbot.com", 241 | "keywords": [ 242 | "date", 243 | "datetime", 244 | "time" 245 | ], 246 | "time": "2019-08-31T16:37:55+00:00" 247 | }, 248 | { 249 | "name": "psr/container", 250 | "version": "1.0.0", 251 | "source": { 252 | "type": "git", 253 | "url": "https://github.com/php-fig/container.git", 254 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" 255 | }, 256 | "dist": { 257 | "type": "zip", 258 | "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 259 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 260 | "shasum": "" 261 | }, 262 | "require": { 263 | "php": ">=5.3.0" 264 | }, 265 | "type": "library", 266 | "extra": { 267 | "branch-alias": { 268 | "dev-master": "1.0.x-dev" 269 | } 270 | }, 271 | "autoload": { 272 | "psr-4": { 273 | "Psr\\Container\\": "src/" 274 | } 275 | }, 276 | "notification-url": "https://packagist.org/downloads/", 277 | "license": [ 278 | "MIT" 279 | ], 280 | "authors": [ 281 | { 282 | "name": "PHP-FIG", 283 | "homepage": "http://www.php-fig.org/" 284 | } 285 | ], 286 | "description": "Common Container Interface (PHP FIG PSR-11)", 287 | "homepage": "https://github.com/php-fig/container", 288 | "keywords": [ 289 | "PSR-11", 290 | "container", 291 | "container-interface", 292 | "container-interop", 293 | "psr" 294 | ], 295 | "time": "2017-02-14T16:28:37+00:00" 296 | }, 297 | { 298 | "name": "psr/simple-cache", 299 | "version": "1.0.1", 300 | "source": { 301 | "type": "git", 302 | "url": "https://github.com/php-fig/simple-cache.git", 303 | "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" 304 | }, 305 | "dist": { 306 | "type": "zip", 307 | "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", 308 | "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", 309 | "shasum": "" 310 | }, 311 | "require": { 312 | "php": ">=5.3.0" 313 | }, 314 | "type": "library", 315 | "extra": { 316 | "branch-alias": { 317 | "dev-master": "1.0.x-dev" 318 | } 319 | }, 320 | "autoload": { 321 | "psr-4": { 322 | "Psr\\SimpleCache\\": "src/" 323 | } 324 | }, 325 | "notification-url": "https://packagist.org/downloads/", 326 | "license": [ 327 | "MIT" 328 | ], 329 | "authors": [ 330 | { 331 | "name": "PHP-FIG", 332 | "homepage": "http://www.php-fig.org/" 333 | } 334 | ], 335 | "description": "Common interfaces for simple caching", 336 | "keywords": [ 337 | "cache", 338 | "caching", 339 | "psr", 340 | "psr-16", 341 | "simple-cache" 342 | ], 343 | "time": "2017-10-23T01:57:42+00:00" 344 | }, 345 | { 346 | "name": "symfony/polyfill-mbstring", 347 | "version": "v1.12.0", 348 | "source": { 349 | "type": "git", 350 | "url": "https://github.com/symfony/polyfill-mbstring.git", 351 | "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" 352 | }, 353 | "dist": { 354 | "type": "zip", 355 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", 356 | "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", 357 | "shasum": "" 358 | }, 359 | "require": { 360 | "php": ">=5.3.3" 361 | }, 362 | "suggest": { 363 | "ext-mbstring": "For best performance" 364 | }, 365 | "type": "library", 366 | "extra": { 367 | "branch-alias": { 368 | "dev-master": "1.12-dev" 369 | } 370 | }, 371 | "autoload": { 372 | "psr-4": { 373 | "Symfony\\Polyfill\\Mbstring\\": "" 374 | }, 375 | "files": [ 376 | "bootstrap.php" 377 | ] 378 | }, 379 | "notification-url": "https://packagist.org/downloads/", 380 | "license": [ 381 | "MIT" 382 | ], 383 | "authors": [ 384 | { 385 | "name": "Nicolas Grekas", 386 | "email": "p@tchwork.com" 387 | }, 388 | { 389 | "name": "Symfony Community", 390 | "homepage": "https://symfony.com/contributors" 391 | } 392 | ], 393 | "description": "Symfony polyfill for the Mbstring extension", 394 | "homepage": "https://symfony.com", 395 | "keywords": [ 396 | "compatibility", 397 | "mbstring", 398 | "polyfill", 399 | "portable", 400 | "shim" 401 | ], 402 | "time": "2019-08-06T08:03:45+00:00" 403 | }, 404 | { 405 | "name": "symfony/translation", 406 | "version": "v4.3.4", 407 | "source": { 408 | "type": "git", 409 | "url": "https://github.com/symfony/translation.git", 410 | "reference": "28498169dd334095fa981827992f3a24d50fed0f" 411 | }, 412 | "dist": { 413 | "type": "zip", 414 | "url": "https://api.github.com/repos/symfony/translation/zipball/28498169dd334095fa981827992f3a24d50fed0f", 415 | "reference": "28498169dd334095fa981827992f3a24d50fed0f", 416 | "shasum": "" 417 | }, 418 | "require": { 419 | "php": "^7.1.3", 420 | "symfony/polyfill-mbstring": "~1.0", 421 | "symfony/translation-contracts": "^1.1.6" 422 | }, 423 | "conflict": { 424 | "symfony/config": "<3.4", 425 | "symfony/dependency-injection": "<3.4", 426 | "symfony/yaml": "<3.4" 427 | }, 428 | "provide": { 429 | "symfony/translation-implementation": "1.0" 430 | }, 431 | "require-dev": { 432 | "psr/log": "~1.0", 433 | "symfony/config": "~3.4|~4.0", 434 | "symfony/console": "~3.4|~4.0", 435 | "symfony/dependency-injection": "~3.4|~4.0", 436 | "symfony/finder": "~2.8|~3.0|~4.0", 437 | "symfony/http-kernel": "~3.4|~4.0", 438 | "symfony/intl": "~3.4|~4.0", 439 | "symfony/service-contracts": "^1.1.2", 440 | "symfony/var-dumper": "~3.4|~4.0", 441 | "symfony/yaml": "~3.4|~4.0" 442 | }, 443 | "suggest": { 444 | "psr/log-implementation": "To use logging capability in translator", 445 | "symfony/config": "", 446 | "symfony/yaml": "" 447 | }, 448 | "type": "library", 449 | "extra": { 450 | "branch-alias": { 451 | "dev-master": "4.3-dev" 452 | } 453 | }, 454 | "autoload": { 455 | "psr-4": { 456 | "Symfony\\Component\\Translation\\": "" 457 | }, 458 | "exclude-from-classmap": [ 459 | "/Tests/" 460 | ] 461 | }, 462 | "notification-url": "https://packagist.org/downloads/", 463 | "license": [ 464 | "MIT" 465 | ], 466 | "authors": [ 467 | { 468 | "name": "Fabien Potencier", 469 | "email": "fabien@symfony.com" 470 | }, 471 | { 472 | "name": "Symfony Community", 473 | "homepage": "https://symfony.com/contributors" 474 | } 475 | ], 476 | "description": "Symfony Translation Component", 477 | "homepage": "https://symfony.com", 478 | "time": "2019-08-26T08:55:16+00:00" 479 | }, 480 | { 481 | "name": "symfony/translation-contracts", 482 | "version": "v1.1.6", 483 | "source": { 484 | "type": "git", 485 | "url": "https://github.com/symfony/translation-contracts.git", 486 | "reference": "325b17c24f3ee23cbecfa63ba809c6d89b5fa04a" 487 | }, 488 | "dist": { 489 | "type": "zip", 490 | "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/325b17c24f3ee23cbecfa63ba809c6d89b5fa04a", 491 | "reference": "325b17c24f3ee23cbecfa63ba809c6d89b5fa04a", 492 | "shasum": "" 493 | }, 494 | "require": { 495 | "php": "^7.1.3" 496 | }, 497 | "suggest": { 498 | "symfony/translation-implementation": "" 499 | }, 500 | "type": "library", 501 | "extra": { 502 | "branch-alias": { 503 | "dev-master": "1.1-dev" 504 | } 505 | }, 506 | "autoload": { 507 | "psr-4": { 508 | "Symfony\\Contracts\\Translation\\": "" 509 | } 510 | }, 511 | "notification-url": "https://packagist.org/downloads/", 512 | "license": [ 513 | "MIT" 514 | ], 515 | "authors": [ 516 | { 517 | "name": "Nicolas Grekas", 518 | "email": "p@tchwork.com" 519 | }, 520 | { 521 | "name": "Symfony Community", 522 | "homepage": "https://symfony.com/contributors" 523 | } 524 | ], 525 | "description": "Generic abstractions related to translation", 526 | "homepage": "https://symfony.com", 527 | "keywords": [ 528 | "abstractions", 529 | "contracts", 530 | "decoupling", 531 | "interfaces", 532 | "interoperability", 533 | "standards" 534 | ], 535 | "time": "2019-08-02T12:15:04+00:00" 536 | } 537 | ], 538 | "packages-dev": [], 539 | "aliases": [], 540 | "minimum-stability": "stable", 541 | "stability-flags": [], 542 | "prefer-stable": false, 543 | "prefer-lowest": false, 544 | "platform": { 545 | "php": "~5.5|~7.0" 546 | }, 547 | "platform-dev": [] 548 | } 549 | -------------------------------------------------------------------------------- /src/TinymceController.php: -------------------------------------------------------------------------------- 1 | file('image'); 19 | 20 | $filename = 'image_'.time().'_'.$image->hashName(); 21 | $image = $image->move(public_path('img'), $filename); 22 | 23 | return mce_back($filename); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/TinymceServiceProvider.php: -------------------------------------------------------------------------------- 1 | loadViewsFrom(realpath(__DIR__.'/views'), 'mceImageUpload'); 25 | 26 | // load routes 27 | include __DIR__.'/routes.php'; 28 | 29 | // ability to publish view 30 | $this->publishes([ 31 | __DIR__.'/views' => base_path('resources/views/petehouston/tinymce'), 32 | ]); 33 | } 34 | 35 | /** 36 | * Register the service provider. 37 | * 38 | * @return void 39 | */ 40 | public function register() 41 | { 42 | // load routes 43 | include __DIR__.'/routes.php'; 44 | 45 | // load controller 46 | $this->app->make('Petehouston\Tinymce\TinymceController'); 47 | 48 | // load helper 49 | include __DIR__.'/helpers.php'; 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /src/helpers.php: -------------------------------------------------------------------------------- 1 | 15 | top.$('.mce-btn.mce-open').parent().find('.mce-textbox').val('/img/".$filename."').closest('.mce-window').find('.mce-primary').click(); 16 | 17 | "); 18 | } 19 | } -------------------------------------------------------------------------------- /src/routes.php: -------------------------------------------------------------------------------- 1 | name('tinymce.imageupload'); -------------------------------------------------------------------------------- /src/views/example.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TinyMCE Simple Image Upload 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 |
14 |
15 | TinyMCE Simple Image Upload 16 |
17 |
18 |
19 | 20 |
21 |
22 |
23 |
24 |
25 |
26 | @include('mceImageUpload::upload_form') 27 | 28 | 29 | 30 | 49 | 50 | Fork me on GitHub 51 | 52 | -------------------------------------------------------------------------------- /src/views/upload_form.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 |
--------------------------------------------------------------------------------