Got this running by generating the png's and referencing the image with an absolute URL inside an img tag. Thanks for the help!
$generator = new BarcodeGenerator();
$barcode = $generator->getBarcodeObj('C39E', $voucherCode, 240, 60, "#000", [30, 10, 30, 10]);
//Save image to folder
$directory = "public://vouchers/";
$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
$this->fileSystem->saveData($barcode->getPngData(), $directory . $filename, FileExists::Replace);
I have an opportunity on code to generate the image. Drush would be more work to perform at run time. Are there any public methods / services we could leverage?
newaytech → created an issue.
Thanks for the feedback and all the work on the module - it's a great resource. I'm using the MimeMail module combined with the Sendgrid module - and have been using these for a while now to send HTML emails from Drupal Commerce (tables / buttons / images).
The pertintent source of the HTML email is here:
<span style=3D"vertical-align: middle;width: 400px; displ=
ay: inline-block;"><img alt=3D"Embedded Image" src=3D"data:image/png;base64=
,iVBORw0KGgoAAAANSUhEUgAAAZAAAACgAQMAAAAYfKiWAAAABlBMVEX///8AAABVwtN+AAAAAX=
RSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAGpJREFUWIXty7ENgCAURVFcQFs6Z7Cz+=
zMZB2ADHIFVfvcHYQEpTQjKGCbc27y84jhHRESDpf5N5XrU53q0ydac7lnM91mKSXYhiu65hrhp=
f2cTg0AgEAgEAoFAIBAIBAKBQCB/JERENFgfUP01AsCN8GsAAAAASUVORK5CYII=3D"></span>
</td>
</tr>
</tbody>
</table>
I have read that embedded images do not work with Gmail?
Once I have this working for Gmail - I'll move onto using Litmus to test the most popular email clients before delivering the solution to my client.
I tried svg - and they don't work with many email clients either
Is it possible to generate a filesystem image to the public web folder with the module - once I've done that - I can refer to the real png from within the email. I have a hunch that may be the lowest common denominator we need to drop to...
newaytech → created an issue.
Thanks @tomtech. I've taken the plunge and am now using the custom repos for both PHP and Apache...
newaytech → created an issue.
newaytech → created an issue.
Hi there - I'm getting an exact same issue with Vimeo URL parameters. I've put together the following code so far for Vimeo - and it's working - but I can't figure out where the "app_id" value is set - so feel the solution is fragile.
function neway_barrio_sass_preprocess_media_oembed_iframe(array &$variables)
{
$url = Drupal::request()->query->get('url');
$params = UrlHelper::parse($url)['query'];
// Take each param and add together to make a param list separated by &
$query = http_build_query($params);
kint($url);
kint($params);
kint($query);
$original = $variables["media"]->__toString();
kint($original);
if (!empty($params)) {
$original = str_replace('?app_id', '?' . $query . '&app_id', $original);
}
kint($original);
$variables["media"] = IFrameMarkup::create($original);
}
Hoping someone from the community can chime in with some insight. I'm going to explore "hook_oembed_resource_url_alter" next...
Usning Drupal 10.3.6
yes - looks good that.
The merge request uses a backslash "DIRECRTORY_SEPARATOR" - which renders the wrong file path to the href link.
Replacing with "/" fixes it up.
- $path_from_root = str_replace('\\', DIRECTORY_SEPARATOR, $path_from_root);
+ $path_from_root = str_replace('\\', "/", $path_from_root);
Are you able to re-roll as another merge request ?
Hi folks. I use a XAMP stack on Windows 11. Can confirm patch in #6 applied and fixed for me - do you need me to test any other patches? How do I apply the merge request to my setup - I'm using the patch via composer.json right now.
I do get an error message when restoring a production site (linux based) to my local dev - so I need to perform a drush full cache clear - otherwise I can't access the site. Not a showstopper - but just something I've never had to do before - and seems related.
Warning: file_get_contents(/etc/apache2/htdocs/drupal-8/neway-drupal-project/web/themes/contrib/bootstrap_barrio/components/alert\alert.twig): Failed to open stream: No such file or directory in Drupal\Core\Template\Loader\ComponentLoader->getSourceContext() (line 93 of core\lib\Drupal\Core\Template\Loader\ComponentLoader.php).
Drupal\Core\Template\Loader\ComponentLoader->getSourceContext('bootstrap_barrio:alert') (Line: 71)
Twig\Loader\ChainLoader->getSourceContext('bootstrap_barrio:alert') (Line: 380)
Twig\Environment->loadTemplate('__TwigTemplate_5fa659091c48341a12c1ba2127d9481d', 'bootstrap_barrio:alert') (Line: 343)
Twig\Environment->load('bootstrap_barrio:alert') (Line: 466)
Twig\Environment->resolveTemplate('bootstrap_barrio:alert') (Line: 1439)
Twig\Extension\CoreExtension::include(Object, Array, 'bootstrap_barrio:alert', Array) (Line: 45)
__TwigTemplate_bfe96b157a4c1d7d5465c2e2e9c307c6->doDisplay(Array, Array) (Line: 393)
Twig\Template->yield(Array, Array) (Line: 349)
Twig\Template->display(Array) (Line: 364)
Twig\Template->render(Array) (Line: 35)
Twig\TemplateWrapper->render(Array) (Line: 33)
twig_render_template('themes/contrib/bootstrap_barrio/templates/misc/status-messages.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('status_messages', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 248)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 165)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 166)
Drupal\Core\Render\Renderer->renderInIsolation(Array) (Line: 191)
Drupal\Core\Render\Renderer->doRenderPlaceholder(Array) (Line: 228)
Drupal\Core\Render\Renderer->renderPlaceholder('callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&args%5B0%5D&token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA', Array) (Line: 697)
Drupal\big_pipe\Render\BigPipe->renderPlaceholder('callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&args%5B0%5D&token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA', Array) (Line: 524)
Drupal\big_pipe\Render\BigPipe->Drupal\big_pipe\Render\{closure}()
Fiber->start() (Line: 531)
Drupal\big_pipe\Render\BigPipe->sendPlaceholders(Array, Array, Object) (Line: 283)
Drupal\big_pipe\Render\BigPipe->sendContent(Object) (Line: 113)
Drupal\big_pipe\Render\BigPipeResponse->sendContent() (Line: 423)
Symfony\Component\HttpFoundation\Response->send() (Line: 20)
Same issue here - manifested once I updated Bario theme - with new components added.
Path in #6 applied and fixed for me - thanks!
A little further insight here: https://github.com/twbs/bootstrap/issues/40621
Maybe we just sit tight for a fix?
newaytech → created an issue.
Thanks for all the work on the GTM module - sorry I didn't see this issue earlier to chime in...
We use CookieBot to set consent - so need opportunity for that to load - provide consent signals to the dataLayer - for us to then utilise those within the framework of GTM. At the moment with this addition - the placement of all the Google Tag code in the header is causing the dataLayer events to be pushed prior to consent being delivered by CookieBot. The other side effect here is that we pull a heap more Javascript up into the head - slowing the perceived page rendering speed by Google.
Is it possible for me to retrospectively apply a dependency on my CookieBot cookie library such that the cookie code always runs first - at the moment it is being called after the gtag / ajax & gtm javascript files...
newaytech → created an issue.
Great module - this is exactly what I was looking for to help with GDPR policies. I've had a look at the code - but not yest installed. Perhaps refactor the delete method into a single piece of code that is referred to from the batch and cron sections?
Thanks kaszarobert - I've applied your patch via composer.json - works a treat - and we're now tracking promo codes in GA4 via GTM - fantastic!
Thanks kaszarobert - can I add your commit into my composer.json - or do we need a .patch file for that?
newaytech → created an issue.
I've just noticed that all of the tracking on on of my sites has gone dark since implementing the consent code.
I ticked the box in the module - hoping that the cookieless GA4 machine learning would have our back. Only on deeper diving into the pre-reqs of the cookieless GA4 world - do I then read that you need a minimum of 1000 users per day in order for the model to "learn". See here: https://support.google.com/analytics/answer/11161109?hl=en-GB&utm_id=ad
I've had to turn the consent settings off for now for my client - as all his reports went dark - due to the Behavioural Modelling having insufficient data to fill in the gaps - which kinda sucks for the smaller GA4 users...
I guess the only alternative for the smaller user is to have consent banner - and then only gain insight on the users that actually says yes to analytics_storage...
Anybody else seeing this - I've seen another comment over on another issue here that talks of their reports going dark after ticking the box - and I guess this is the reason.
I personally think that the tick box should be off by default - as unless we make the pre-reqs clear - a lot of smaller users may lose tracking altogether.
maybe set the order using dependencies in the libraries.yml?
seeing this:
Entry in services.yml
neway_lintels.breadcrumb:
class: Drupal\neway_lintels\BreadcrumbBuilder
arguments: [ '@entity_type.manager', '@entity.repository' ]
tags:
- { name: breadcrumb_builder, priority: 1004 }
<?php
namespace Drupal\neway_lintels;
use Drupal;
use Drupal\commerce_product\Entity\Product;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Link;
use Drupal\Core\Routing\LinkGeneratorTrait;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository) {
$this->entityTypeManager = $entity_type_manager;
$this->entityRepository = $entity_repository;
}
/**
* By advent of there being a breadcrumb_builder name in the services.yml file - the Symphony framework runs
* the below - to see if it is applicable - if it is - the bigger weight wins
*
* Code by Wayne Foster, Neway Technology Ltd, UK
*
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match): bool {
$allowedRoutes = [
"entity.commerce_product.canonical",
];
$routeName = $route_match->getRouteName();
//dump("bread applies termID: " . $termID . ", routeName:" . $routeName);
return (in_array($routeName, $allowedRoutes));
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match): Breadcrumb {
$breadcrumb = new Breadcrumb();
/** @var Product $entityProduct */
$entityProduct = $route_match->getParameter('commerce_product');
$termID = Drupal::request()->get('term');
/** @var \Drupal\taxonomy\TermStorageInterface $parents */
$parents;
// We have found a term ID on the URL - use it
if ($termID && $termID > 0) {
$parents = $this->entityTypeManager->getStorage('taxonomy_term')
->loadAllParents($termID);
} // if not - then get the first entry on the product category list of taxonomies
else {
$taxonomy_field_name = 'product_category';
/** @var \Drupal\taxonomy\Entity\Term $productCategory */
$productCategory = $entityProduct->$taxonomy_field_name->entity;
//dump("firstCategory", $productCategory);
$parents = $this->entityTypeManager->getStorage('taxonomy_term')
->loadAllParents($productCategory->id());
}
// Add a home page link to the start of the breadcrumb render array
$links[] = Link::createFromRoute(t("Home"), '<front>');
$linksTax = [];
// iterate up the taxonomy parents
foreach ($parents as $parent) {
$parent = $this->entityRepository->getTranslationFromContext($parent);
$linksTax[] = $parent->toLink();
}
$links = array_merge($links, array_reverse($linksTax));
$links[] = Link::createFromRoute($entityProduct->getTitle(), '<none>');
$breadcrumb->setLinks($links);
$breadcrumb->addCacheContexts(['route', 'url.path','url.query_args']);
return $breadcrumb;
}
}
Hey Greg, thanks for the tip around the custom code. I ended up using the new BreadcrumbBuilderInterface approach - and pulling the taxonomy ID either from the URL - or the first entry in the list of taxonomies I have on the product. Works a treat - thanks for the hint!
newaytech → created an issue.
Hi folks - just updated to the latest version - and can see that the consent event is fired after the container loaded event. Any further config / GTM config required?
I have a requirement here where a commerce product can be reached via several paths. I want to have a URL per taxonomy term - so need to be able to have multiple URL aliases per Commerce Product - all with a single canonical. Does this patch work with Commerce Products - I saw in a note that there was an issue? Thanks for the work here - really enjoying D8/9/10...
newaytech → created an issue.
Fantastic @Berdir - thanks for the contrib...
newaytech → created an issue.
For anyone else landing here - for what it's worth - I rewrote a few GTM triggers and am now using the Google Tag module. I thought that updating the module with the versions numbers would work (thanks for the patch) - but the composer.json file looks at the GIT repo for compatibility.
newaytech → created an issue.
Thanks for the great module folks and support in bringing up to date for D10. Do we have an ETA for a new release with D10 support baked in?
Hey @brandon - thanks for checking in. Our setup is:
10:10 AM root@web2:#~ php -v
PHP 8.1.2-1ubuntu2.13 (cli) (built: Jun 28 2023 14:01:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.13, Copyright (c), by Zend Technologies
10:11 AM root@web2:#~ apachectl status
Apache Server Status for localhost (via 127.0.0.1)
Server Version: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2
Server MPM: prefork
Server Built: 2023-03-01T22:43:55
__________________________________________________________________
Current Time: Friday, 07-Jul-2023 10:11:14 BST
Restart Time: Wednesday, 05-Jul-2023 13:36:40 BST
Parent Server Config. Generation: 11
Parent Server MPM Generation: 10
Server uptime: 1 day 20 hours 34 minutes 33 seconds
Server load: 0.05 0.07 0.08
Total accesses: 98105 - Total Traffic: 636.4 MB - Total Duration:
5193991
CPU Usage: u264.91 s114.04 cu6035.18 cs1408.11 - 4.87% CPU load
.611 requests/sec - 4158 B/second - 6.6 kB/request - 52.9432 ms/request
1 requests currently being processed, 6 idle workers
I did try php-fpm - but on the apache bench performance tests I ran - it was slower than out of the box PHP - so kept the install simple.
I've been running Ubuntu 22.04.06 for several months now - with the stock PHP running - and our log files are all clear. Could it be something else causing the error @artem_sylchuk ?
Arrived here after getting: EntityMetadataWrapperException: Unknown data property commerce_line_items. in EntityStructureWrapper->getPropertyInfo() (line 360 of /etc/apache2/htdocs/drupal-7/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
Ran the commerce repair module but to no avail.
Patch @ #6 fixed for me - thanks folks!
In light of the PHP version lock > PHP8.1.2 in Ubuntu 22.04 LTS - what is the recommended approach here? Trust in the backported patches from Ubuntu - or add in "ppa:ondrej/php" - and use 8.1 latest?
Just been caught by this too. Upgraded from Ubuntu 20.04.06 LTS > 22.04.2 LTS - then was greeted by the warning on the status page.
My php reports:
HP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies
Hoping that by now the bug has been fixed by the Ubuntu team - and made it into the release number 11.
How do we check for the opcache error in question - log files?
same here folks. I added the following to my subthemes variables.scss
// New image variable introduced on 5.5.1
$barrio_path_images: "../images/";
but as others have said - would have expected this to be in the newly introduced variables scss file - for sub themes to then override if required?
Hope I'm not breaking the rules by raising this issue again - but the code that was running perfectly (DestructableInterface to run cron) - alas is now throwing an error:
RuntimeException: Failed to start the session because headers have already been sent by "C:\xampp\apache\htdocs\drupal-8\neway-drupal-project\vendor\symfony\http-foundation\Response.php" at line 1239. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 152 of C:\xampp\apache\htdocs\drupal-8\neway-drupal-project\vendor\symfony\http-foundation\Session\Storage\NativeSessionStorage.php).
I've even disabled every other cron task to try and isolate - but to no avail.
I can get this working again by rolling back my code base back to prior to Feb (Upgrading drupal/core (9.5.2 => 9.5.3))
Is there a better way to invoke an immediate queue processing run - whilst still having the securiyy of any failures getting picked up by cron (and also having the item only processed once?)
I've implemented a workaround by creating a subdomain, media.mydomain.com - pointing to the same IP as my main site - which still gets served the same Drupal instance by way of domain matching. I've then implemented a rule (Cloudflare - other solutions work too) - that for incoming requests with "media" in the hostname - adds a header of:
Content-Security-Policy = frame-ancestors https://*.mydomain.com (this works for uat / www)
The iFrame domain is then set to "https://media.mydomain.com"
Seems to work OK - feels a bit risky to expose a further subdomain to the public - but I'll see how it fairs...
I too have just created a subdomain to clean up my status page warning message (using Cloudflare). Reloaded the page - and the iFramed Vimeo content no longer appears;
Refused to display 'https://mediatest.mydomain.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Any advice?
I am hoping to install the Shopify PHP library for a microservices project - but get an issue with Guzzle versions:
- Root composer.json requires shopify/shopify-api ^4.2 -> satisfiable by shopify/shopify-api[v4.2.0].
- shopify/shopify-api v4.2.0 requires guzzlehttp/guzzle ^7.0 -> found guzzlehttp/guzzle[dev-master, 7.0.0-beta.1, ..., 7.5.x-dev (alias of dev-master)] but the package is fixed to 6.5.8 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
It would be great if we could get some guidance as to how to migrate safely toward Guzzle 7...
Thanks for the patch #151 - this applied for me on Drupal 9.5 - and I was able to change the offline page within a minimal theme I have created just for offline pages across all my multisites.
The issues I cannot fathom - is how to elegantly alter the response code of the error page. If we have a database issue - I need a 504 - such that my upstream proxy serves an interim cached site page - any thoughts around this? Previously, we could achieve that using a preprocess hook - but as we're bypassing the drupal ecosystem and going direct via twig - I can't see how to alter the response code.