I have the following file named background_image_style.module
In my Drupal 8.3.3 site, paragraphs.module is at MySite/web/modules/contrib/paragraphs/paragraphs.module.
I installed the site and all contributed modules with Composer.
composer require drupal/paragraphs
vendor\bin\drupal module:install paragraphs
Where does my hook module go? (I just copied it in where the paragraphs.module is.) Are there any other overhead steps that needs to be done (e.g. editing other files)?
I tried several locations and cleared the cache each time.
/**
* Implements paragraphs().
*/
function background_image_style_preprocess_paragraph__banner(&$variables) {
$paragraph = $variables['paragraph'];
if (!$paragraph->field_image->isEmpty()) {
$image = $paragraph->field_image->entity->url();
$variables['attributes']['style'][] = 'background-image: url("' . $image. '");';
$variables['attributes']['style'][] = 'background-size: cover;';
$variables['attributes']['style'][] = 'background-position: center center;';
}