I have the following file named background_image_style.module
In my drupal 8.3.3 site the 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
My question is... Where does the hook module go? Does it need to be installed with Composer (I just copied it in where paragraphs.module is) Are there any other overhead steps that needs to be done? (editing other files?)
I tried several locations and cleared all caches each time. Thanks for any help or ideas!
/**
* 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;';
}
}