OrchardCMS/OrchardCore · error · Error

You must set a Giphy API Key

Error message

You must set a Giphy API Key

What it means

The Trumbowyg Giphy plugin searches api.giphy.com and requires an API key configured at plugins.giphy.apiKey. When the key is null (or missing entirely from the plugin config) clicking the Giphy button throws this Error before making the AJAX call.

Solutions

  1. Set the API key in editor config: plugins: { giphy: { apiKey: 'YOUR_GIPHY_KEY' } }
  2. Obtain a free Giphy API key and inject it from server-side configuration instead of hardcoding null
  3. Disable/hide the Giphy button when no key is configured

Example fix

// before
$('#editor').trumbowyg({ plugins: { giphy: { apiKey: null } } });
// after
$('#editor').trumbowyg({ plugins: { giphy: { apiKey: 'GIPHY_API_KEY', rating: 'g' } } });
Defensive patterns

Strategy: validation

Validate before calling

const giphyCfg = editorConfig.plugins?.giphy || {};
if (!giphyCfg.apiKey) { /* hide the Giphy button or bail out before plugin init */ }

Type guard

function hasGiphyKey(cfg) { return typeof cfg?.plugins?.giphy?.apiKey === 'string' && cfg.plugins.giphy.apiKey.length > 0; }

Try / catch

try { openGiphyPicker(); } catch (e) { if (e.message.includes('Giphy API Key')) alert('Giphy is not configured for this site.'); }

Prevention

When it happens

Trigger: Registering the giphy plugin in the Trumbowyg editor but never setting trumbowyg.o.plugins.giphy.apiKey, then clicking the Giphy toolbar button.

Common situations: Deploying a configured-locally editor where the key was injected via environment/config that isn't present in production; forgetting the key when copying the plugin setup snippet; leaving apiKey: null as a placeholder.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/6a20cd2633aad72f. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Resources/Assets/trumbowyg/plugins/giphy/trumbowyg.giphy.js:154

    apiKey: null,
    throttleDelay: 300,
    noResultGifUrl: 'https://media.giphy.com/media/2Faz9FbRzmwxY0pZS/giphy.gif'
  };

  // Add dropdown with font sizes
  $.extend(true, $.trumbowyg, {
    plugins: {
      giphy: {
        init: function (trumbowyg) {
          trumbowyg.o.plugins.giphy = $.extend({},
            defaultOptions,
            trumbowyg.o.plugins.giphy || {}
          );

          trumbowyg.addBtnDef('giphy', {
            fn: function() {
              if (trumbowyg.o.plugins.giphy.apiKey === null) {
                throw new Error('You must set a Giphy API Key');
              }

              var BASE_URL = 'https://api.giphy.com/v1/gifs/search?api_key=' + trumbowyg.o.plugins.giphy.apiKey + '&rating=' + trumbowyg.o.plugins.giphy.rating,
                  DEFAULT_URL = BASE_URL.replace('/search', '/trending');
              var previousAjaxCall = {abort: function () {}};
              var prefix = trumbowyg.o.prefix;

              // Create and open the modal
              var searchInput = '<input name="" class="' + prefix + 'giphy-search" placeholder="Search a GIF" autofocus="autofocus">',
                  closeButton = '<button class="' + prefix + 'giphy-close" title="' + trumbowyg.lang.close + '"><svg><use xlink:href="' + trumbowyg.svgPath + '#' + prefix + 'close"/></svg></button>',
                  poweredByGiphy = '<div class="' + prefix + 'powered-by-giphy"><span>Powered by</span>' + giphyLogo + '</div>',
                  giphyModalHtml = searchInput + closeButton + poweredByGiphy + '<div class="' + prefix + 'giphy-modal-scroll"><div class="' + prefix + 'giphy-modal"></div></div>';

              trumbowyg
                .openModal(null, giphyModalHtml, false)
                .one(CANCEL_EVENT, function () {
                  try {
                    previousAjaxCall.abort();

View on GitHub (pinned to 4306c0717f)