All Collections
Installing SnapWidget on your website
How do I add an Instagram widget to my Drupal 10 website?
How do I add an Instagram widget to my Drupal 10 website?

Find out how you can add SnapWidget to your Drupal 10 website 🎯

Henk Schutte avatar
Written by Henk Schutte
Updated over a week ago

Adding your Instagram, Facebook or Twitter widget to your Drupal 9 website is easy. Follow these steps to create your widget.

Once you've created your widget, follow the appropriate steps below to add it to your website.

NB! First things first - Drupal 10 uses the CKEditor 5 editor to allow editing article, page and block content. There are a few options that you have to set up to allow Custom HTML such as <script>, <link> and <iframe> tags. If you do not set this up the editor will just strip these out of your snippet.

A. Set up CKEditor 5 to allow Custom HTML.

  1. Log in to your Drupal 10 account.

  2. On your Dashboard, select Configuration on the Admin toolbar.

  3. Under Content Authoring, select Text formats and editors.

  4. In the Name column, move the Full HTML set to the top of the list and click on Save. This will set the Full HTML option as the default selection when editing content.

  5. Click on Configure under Operations to configure the Full HTML set.

  6. On the setup page for Full HTML make sure that Administrator is selected under Roles.

  7. Select CKEditor 5 under Text editor.

  8. To allow proper formatting during content editing (when you insert your snippet) make the following changes to the Editor Toolbar under Toolbar Configuration.

    • (a) Below is a possible original Toolbar layout (this depends on how Drupal 10 was set up / used before you started adding the SnapWidget snippet).

    • Add the Text Alignment button to the Active toolbar if not already added. (Drag the items from the Available buttons group onto the Active toolbar formatting group). This will allow you to change the justification of your displayed widget (only applicable to the Grid Display widget).

    • The Active toolbar should now have the following items available.

  9. Under Enabled filters make sure the following options are NOT selected:

  10. Click on the Save configuration button at the bottom of the Configuration page.

  11. CKEditor 5 has now been set up to allow adding Custom HTML in any Content area on your Drupal 10 website.

B. Adding your widget to your website.

  • Drupal 10 uses blocks to display content that can be displayed in regions (such as content, footer or sidebar) on your page. You can create Custom blocks, i.e. it allows the user to create blocks with Custom content which makes displaying your widget a lot easier.

  • See Working with blocks and Block module for documentation regarding the use of blocks in Drupal 10.

  • Drupal 10 also allows Custom HTML to be added directly to content such as basic pages and articles. For the purpose of this tutorial we will be looking at adding the widget directly to a web page via Custom HTML.

Note: In this tutorial the Drupal 10 website has been set up with the default Olivero 10.1.2 theme. The process for adding your snippet to any other theme is exactly the same. The only difference will be the resulting displayed website.

C. Adding your Grid Display Widget to your website.

  1. Log in to your Drupal 10 account and on your Dashboard, select Content on the Admin toolbar.

  2. Click on Edit for the Content item (in this case, Basic page) you wish to edit on the displayed Content list.

  3. On the Edit Basic Page form, make sure the Source option is selected to allow adding Custom HTML.

  4. Insert your snippet in the Body part.

  5. Click on the Source button again to return to the normal editor to preview your widget (please note that this can sometimes differ from the actual display on your live webpage).

  6. Your widget will display as follows on your live website.

  7. The widget will be displayed full width, i.e. the full available area on your web page. This is due to the iframe width set to 100%. If you want to display the widget smaller you can change the width to e.g. 50%. Please note that if you make the widget width to small the Social Media buttons won’t be displayed and you also won’t be able to click on an image to display it in a lightbox.

  8. This will display the widget smaller but it will be left justified.

  9. If you want to center the widget in the display area, return to the editor but do not click on the Source button (the preview will be displayed). Select the HTML object and click on the Align center button on the Formatting toolbar.

  10. Your widget will now be displayed center justified.

  11. Clicking on any of the images in the widget will display the image in a Lightbox.

D. Adding your SlideShow Display Widget to your website.

  1. If you added the standard responsive SlideShow widget, it will be displayed as follows.

  2. The widget will be displayed at ~30% of available area and left justified. The size as well as the justification cannot be changed. If this is OK for you, skip the following steps.

  3. To enable us to change the width (and height to keep it at a 1:1 ratio) we will have to make some changes to our widget.

  4. Create a non-responsive SlideShow widget on your SnapWidget dashboard. The width and height are not important, you can set them e.g. to 200px each.

  5. The non-responsive SlideShow widget will display as follows.

  6. We are going to add some HTML and CSS code to our snippet to create an area where the snippet will be displayed. The area will be basically as follows:

  7. Make the following changes to the snippet.

    • Add 2 <div> areas with the following styles (the ids are just for explanatory purposes for this tutorial, they are not used for any other purpose so you can actually leave them out).

      <div id=”wrapper” style=”width: 40%; margin: 0 auto;”>

      This sets the wrapper to 40% of available width and center-justified. With this width setting we can change the width of the snippet to any width we want but please note that if you make the width < 30% the social media buttons won’t be displayed properly on the images. This all depends on the screen size where your page is displayed on.

      <div id="container" style="top: 0; height: 0; width: 100%; padding-bottom: 100%; overflow: hidden; position: relative; margin: 0 auto;">

      This sets the area used to display the iframe at 100% of the wrapper width as well as height = 100% of the width.

    • Remove the width and height attributes of the style part of the iframe and replace them with the indicated attributes

      left: 0; width: 100%; height: 100%; position: absolute;

  8. Your widget will be displayed as follows with a Wrapper width=40%. The widget will also be responsive.

    Note: Remember if you make the size of the widget too small it won’t be able to display the Social media icons and you will also not be able to click on an image to display it in the Lightbox.

  9. Clicking on any of the images in the grid will display it in a Lightbox display.

Did this answer your question?