v4.0.0

  • Added compatibility for v1.0 (By @Ralkage)

Updating

composer update therealsujitk/flarum-ext-gifs
a month later

Hello~

When I use this extension on my forum.

I can preview the gif on the first discussion post, however, the gif won't show up after I submit my post.

The original post is like

![Giphy - Happy I Love You GIF by Life of a Potato](https://media0.giphy.com/media/UuB5lh1bL1Dl6svihe/giphy.gif?cid=b3505e61p9961fxn3d0pey443zuqfagzqf464k4m2he181m6&rid=giphy.gif&ct=g)

and posted one is this

Giphy - Happy I Love you GIF by Life of a Potata

And after the first one, no previews was showed. I now use the beta version of the Giphy API key.

I noticed that actually, I can post Giphy here. Yet, it won't work in my website. Could this is because of my server?

    ash3T is your website publicly accessible? If you don't mind sharing the URL to a public discussion where we can see the issue, this could help diagnose the issue.

    If it works here but not on your server, most likely there is a configuration that prevents loading some files, or if the content doesn't render as image at all maybe there's some sort of Markdown conflict with another extension.

    ctml Thanks! Did you see the Gif alive in the post? Or you can see it preview in the draft(I can see that too). I tried again still not showing the gif photos, not on my phone as well.

    • ctml replied to this.

      ash3T

      You can see some errors thrown throughout forum. Maybe some filesystem permission issues as I don't think flarum would normally throw errors that would reveal underlying directory structure, unless you have debug mode on. Anyways, someone else here could probably better decipher than I could so I'll leave it to the experts 😉

      {"errors":[{"status":"403","code":"permission_denied","detail":"Flarum\\User\\Exception\\PermissionDeniedException in \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/User\/User.php:606\nStack trace:\n#0 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/User\/User.php(634): Flarum\\User\\User-\u003EassertPermission(false)\n#1 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/fof\/secure-https\/src\/Api\/Controllers\/GetImageUrlController.php(44): Flarum\\User\\User-\u003EassertCan(\u0027viewDiscussions\u0027)\n#2 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/RouteHandlerFactory.php(41): FoF\\SecureHttps\\Api\\Controllers\\GetImageUrlController-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#3 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/ExecuteRoute.php(27): Flarum\\Http\\RouteHandlerFactory-\u003EFlarum\\Http\\{closure}(Object(Laminas\\Diactoros\\ServerRequest), Array)\n#4 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\ExecuteRoute-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Closure))\n#5 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Api\/Middleware\/ThrottleApi.php(33): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#6 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Api\\Middleware\\ThrottleApi-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#7 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/CheckCsrfToken.php(36): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#8 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\CheckCsrfToken-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#9 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/ResolveRoute.php(67): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#10 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\ResolveRoute-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#11 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/SetLocale.php(51): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#12 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\SetLocale-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#13 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/AuthenticateWithHeader.php(56): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#14 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\AuthenticateWithHeader-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#15 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/AuthenticateWithSession.php(31): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#16 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\AuthenticateWithSession-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#17 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/RememberFromCookie.php(52): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#18 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\RememberFromCookie-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#19 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/StartSession.php(61): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#20 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\StartSession-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#21 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Api\/Middleware\/FakeHttpMethods.php(29): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#22 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Api\\Middleware\\FakeHttpMethods-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#23 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/ParseJsonBody.php(28): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#24 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\ParseJsonBody-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#25 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/HandleErrors.php(57): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#26 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\HandleErrors-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#27 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/InjectActorReference.php(25): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#28 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\InjectActorReference-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#29 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/MiddlewarePipe.php(76): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#30 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/middlewares\/request-handler\/src\/RequestHandler.php(84): Laminas\\Stratigility\\MiddlewarePipe-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#31 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Middlewares\\RequestHandler-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#32 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/middlewares\/base-path-router\/src\/BasePathRouter.php(101): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#33 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Middlewares\\BasePathRouter-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#34 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Middleware\/OriginalMessages.php(36): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#35 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Laminas\\Stratigility\\Middleware\\OriginalMessages-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#36 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/middlewares\/base-path\/src\/BasePath.php(73): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#37 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Middlewares\\BasePath-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#38 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Middleware\/ProcessIp.php(24): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#39 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/Next.php(51): Flarum\\Http\\Middleware\\ProcessIp-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#40 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/MiddlewarePipe.php(76): Laminas\\Stratigility\\Next-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#41 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-stratigility\/src\/MiddlewarePipe.php(65): Laminas\\Stratigility\\MiddlewarePipe-\u003Eprocess(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\EmptyPipelineHandler))\n#42 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/laminas\/laminas-httphandlerrunner\/src\/RequestHandlerRunner.php(96): Laminas\\Stratigility\\MiddlewarePipe-\u003Ehandle(Object(Laminas\\Diactoros\\ServerRequest))\n#43 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/vendor\/flarum\/core\/src\/Http\/Server.php(44): Laminas\\HttpHandlerRunner\\RequestHandlerRunner-\u003Erun()\n#44 \/home\/vol19_1\/freehost4u.org\/trfr1_28952748\/htdocs\/index.php(26): Flarum\\Http\\Server-\u003Elisten()\n#45 {main}"}]}

      17 days later

      v4.1.0

      • Improved design
      • Added trending terms
      • Added a favourites option
      • Added Tenor support

      Updating

      composer update therealsujitk/flarum-ext-gifs

      Note: Please disable and re-enable this extension after the update, and don't forget to note down your API key before you do. You'll be required to re-enter it.

        I've basically tried my best to recreate the GIFs dialog from Discord 😛. I've rewritten almost the entire extension after my college finally gave us a break, cleaned up everything and actually used the Flarum API 😅 this time. Hopefully this makes it easier for people to contribute in future when I'm not able to 😇. The source code is on GitHub if anyone's interested. To get your Tenor API key check out the first post in this discussion. (And yes, Tenor is much faster)

          Set up with Tenor support and verified key.
          Doesnt load correctly (Tenor logo missing) and if I use the search, I get an 400 error:
          Invalid value at 'contentfilter' (type.googleapis.com/google.search.tenor.v1.ContentFilter.Enum), ""

          There should be input fields for the auth code per API url
          Giphy API Key: _____
          Tenor API Key: _____

          Otherwise you have to search them after switching the provider

            phloo I don't follow. From what you're telling me, I don't think you've configured it correctly in the admin panel. Did you disable and re-enable the extension? You can't use both providers together, for one they both require attributions.

              With the update the API key was deleted as you put in the note, even if the old string does not appear it is deleted from the database? or you have to do it manually?

                Darkle The old setting therealsujitk-gifs.giphy_api_key in the settings table can be safely deleted. I haven't done it (don't know if it's possible), so if you want to you'll have to manually do it. But if it is possible through code, I'll do it in a future release.

                  therealsujitk I didn't mean to use both providers together. My suggestion to add an input field per GIF provider is just because you have to search for the credentials after you switch from one to another.

                  For the 400 bad request problem:
                  We use this extension flawlessly with Giphy. After the update I wanted to try out TENOR and changed the provider and API key. There was no info that we have to disable and renable the whole extension to switch providers.
                  Now the Tenor logo shows as intended but searching is still not possible
                  https://g.tenor.com/v1/search?key=XXXXXX&q=hello&contentfilter=&media_filter=minimal&limit=10

                  {
                    "error": {
                      "code": 400,
                      "message": "Invalid value at 'contentfilter' (type.googleapis.com/google.search.tenor.v1.ContentFilter.Enum), \"\"",
                      "status": "INVALID_ARGUMENT",
                      "details": [
                        {
                          "@type": "type.googleapis.com/google.rpc.BadRequest",
                          "fieldViolations": [
                            {
                              "field": "contentfilter",
                              "description": "Invalid value at 'contentfilter' (type.googleapis.com/google.search.tenor.v1.ContentFilter.Enum), \"\""
                            }
                          ]
                        }
                      ]
                    }
                  }