Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Thurmond pthurmond

View GitHub Profile
@pthurmond
pthurmond / .gitignore
Last active July 26, 2022 20:44
Example of a Drupal 8 composer file with patches
View .gitignore
# Ignore directories generated by Composer
/drush/Commands/contrib/
/vendor/
/docroot/core/
/docroot/modules/contrib/
/docroot/themes/contrib/
/docroot/profiles/contrib/
/docroot/libraries/
/docroot/README.md
@pthurmond
pthurmond / README_YouTube_Pause.md
Last active January 7, 2022 21:05
Pause YouTube videos on slide change. Example with SwiperJS and Drupal 9.
View README_YouTube_Pause.md

Notes

This requires one more thing. The YouTube video URL needs parameters to tell it to accept commands. In my application, which is Drupal 9, I use a hook to modify the URL of all YouTube video URLs.

Example URL: https://www.youtube.com/embed/f5piHKZPoP4?rel=0&autoplay=0&enablejsapi=1

Specifically, the "enablejsapi" parameter is what enables this. I will also share a php file with the Drupal hook I used for this.

To learn more about the optional parameters you can pass, look at this documentation: https://developers.google.com/youtube/player_parameters

@pthurmond
pthurmond / associative_array_splicer.php
Last active April 17, 2021 04:10
This is a tool to allow a programmer to easily insert a new associative index into a desired position in a PHP associative array.
View associative_array_splicer.php
<?php
/**
* Insert an associative array into a specific position in an array.
*
* @param array $original
* The original array to add to.
* @param array $new
* The new array of values to insert into the original.
* @param int $offset
* The position in the array ( 0 index ) where the new array should go.