{"record":{"id":"6a20cd2633aad72f","repo":"OrchardCMS/OrchardCore","slug":"you-must-set-a-giphy-api-key","errorCode":null,"errorMessage":"You must set a Giphy API Key","messagePattern":"You must set a Giphy API Key","errorType":"console","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/Assets/trumbowyg/plugins/giphy/trumbowyg.giphy.js","lineNumber":154,"sourceCode":"    apiKey: null,\n    throttleDelay: 300,\n    noResultGifUrl: 'https://media.giphy.com/media/2Faz9FbRzmwxY0pZS/giphy.gif'\n  };\n\n  // Add dropdown with font sizes\n  $.extend(true, $.trumbowyg, {\n    plugins: {\n      giphy: {\n        init: function (trumbowyg) {\n          trumbowyg.o.plugins.giphy = $.extend({},\n            defaultOptions,\n            trumbowyg.o.plugins.giphy || {}\n          );\n\n          trumbowyg.addBtnDef('giphy', {\n            fn: function() {\n              if (trumbowyg.o.plugins.giphy.apiKey === null) {\n                throw new Error('You must set a Giphy API Key');\n              }\n\n              var BASE_URL = 'https://api.giphy.com/v1/gifs/search?api_key=' + trumbowyg.o.plugins.giphy.apiKey + '&rating=' + trumbowyg.o.plugins.giphy.rating,\n                  DEFAULT_URL = BASE_URL.replace('/search', '/trending');\n              var previousAjaxCall = {abort: function () {}};\n              var prefix = trumbowyg.o.prefix;\n\n              // Create and open the modal\n              var searchInput = '<input name=\"\" class=\"' + prefix + 'giphy-search\" placeholder=\"Search a GIF\" autofocus=\"autofocus\">',\n                  closeButton = '<button class=\"' + prefix + 'giphy-close\" title=\"' + trumbowyg.lang.close + '\"><svg><use xlink:href=\"' + trumbowyg.svgPath + '#' + prefix + 'close\"/></svg></button>',\n                  poweredByGiphy = '<div class=\"' + prefix + 'powered-by-giphy\"><span>Powered by</span>' + giphyLogo + '</div>',\n                  giphyModalHtml = searchInput + closeButton + poweredByGiphy + '<div class=\"' + prefix + 'giphy-modal-scroll\"><div class=\"' + prefix + 'giphy-modal\"></div></div>';\n\n              trumbowyg\n                .openModal(null, giphyModalHtml, false)\n                .one(CANCEL_EVENT, function () {\n                  try {\n                    previousAjaxCall.abort();","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/Assets/trumbowyg/plugins/giphy/trumbowyg.giphy.js#L136-L172","documentation":"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.","triggerScenarios":"Registering the giphy plugin in the Trumbowyg editor but never setting trumbowyg.o.plugins.giphy.apiKey, then clicking the Giphy toolbar button.","commonSituations":"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.","solutions":["Set the API key in editor config: plugins: { giphy: { apiKey: 'YOUR_GIPHY_KEY' } }","Obtain a free Giphy API key and inject it from server-side configuration instead of hardcoding null","Disable/hide the Giphy button when no key is configured"],"exampleFix":"// before\n$('#editor').trumbowyg({ plugins: { giphy: { apiKey: null } } });\n// after\n$('#editor').trumbowyg({ plugins: { giphy: { apiKey: 'GIPHY_API_KEY', rating: 'g' } } });","handlingStrategy":"validation","validationCode":"const giphyCfg = editorConfig.plugins?.giphy || {};\nif (!giphyCfg.apiKey) { /* hide the Giphy button or bail out before plugin init */ }","typeGuard":"function hasGiphyKey(cfg) { return typeof cfg?.plugins?.giphy?.apiKey === 'string' && cfg.plugins.giphy.apiKey.length > 0; }","tryCatchPattern":"try { openGiphyPicker(); } catch (e) { if (e.message.includes('Giphy API Key')) alert('Giphy is not configured for this site.'); }","preventionTips":["Inject the Giphy key from server-side settings, never hardcode null placeholders","Validate editor plugin config in a startup self-check","Disable the Giphy button feature when no key is present"],"tags":["javascript","trumbowyg","api-key"],"backgroundTag":"missing-api-key","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}