media – I’m attempting to render responsive images and control art direction. Could somebody see whyI can’t get breakpoints.yml to be respected?

I’m creating a title/ hero-image section that consists of two 50/50 columns at desktop but then stacks at about tablet (e.g. 1024px)

I’m using a custom twig template for this content type.

I want serve WebP images if the users browser will tolerate that, I also want to serve responsive derivatives and control art direction (i.e. different dimensions and cropping depending on screen width).

To that end I’m trying to use the WebP module together with the Responsive Image module and image styles.

I’ve created two responsive image styles (PMP Hero Col One & PMP Hero Col Two) and six image styles (PMP Hero C1 Desktop, PMP Hero C1 Tablet, PMP Hero C1 Phone, PMP Hero C2 Desktop, PMP Hero C2 Tablet, PMP Hero C2 Phone) each with a scale and crop effect.

I’ve created a breakpoints.yml In my theme’s root directory and I can see its breakpoints within the Responsive Image configuration interface.

my_theme.pmp_hero_col_1.phone:
  label: pmp_hero_col_1_phone
  mediaquery: '(max-width: 900px)'
  weight: 0
  multipliers: 
    - 1x
  group: neiu_main.pmp_hero_col_1
my_theme.pmp_hero_col_1.tablet:
  label: pmp_hero_col_1_tablet
  mediaquery: '(max-width: 1024px)'
  weight: 1
  multipliers: 
    - 1x
  group: neiu_main.pmp_hero_col_1
my_theme.pmp_hero_col_1.desktop: 
  label: pmp_hero_col_1_desktop
  mediaquery: '(min-width: 1025px)'
  weight: 2
  multipliers: 
    - 1x
  group: neiu_main.pmp_hero_col_1 
my_theme.pmp_hero_col_2.phone:
  label: pmp_hero_col_2_phone
  mediaquery: '(max-width: 900px)'
  weight: 0
  multipliers: 
    - 1x
  group: neiu_main.pmp_hero_col_2
my_theme.pmp_hero_col_2.tablet:
  label: pmp_hero_col_2_tablet
  mediaquery: '(max-width: 1024px)'
  weight: 1
  multipliers: 
    - 1x
  group: neiu_main.pmp_hero_col_2  
my_theme.pmp_hero_col_2.desktop:
  label: pmp_hero_col_2_desktop
  mediaquery: '(min-width: 1025px)'
  weight: 2
  multipliers: 
    - 1x
  group: neiu_main.pmp_hero_col_2 

I’ve selected the appropriate breakpoint group in each of my responsive image styles.
Within each responsive image style I’ve selected “Select a single image style.” for each breakpoint and associated the image style I want with it.

I’ve tried setting the fallback image style to “None (original image)” & “empty image”.

I’ve tried rendering the responsive image style in my template like:

{{ drupal_image(node.field_pmp_hero_image.entity.uri.value, 'pmp_hero_col_two', responsive=true) }}

and like:

{% set heroCol2ImagePath = node.field_pmp_hero_image.entity.uri.value %}

{% 
    set heroCol2ResponsiveImageStyle = {
        '#theme': 'responsive_image',
        '#responsive_image_style_id': 'pmp_hero_col_two',
        '#uri': heroCol2ImagePath,
        '#attributes': { class: 'img-responsive', alt: 'MBA Students' },
    } 
%}

{{ heroCol2ResponsiveImageStyle }}

In both cases I do get the picture tag and the appropriate srcsets:

HTML Picture tag markup

Also the derivatives are written to the file system in the appropriate directories and are available.

The problem I’m experiencing is that the breakpoints.yml is never respected i.e. the image never changes to the appropriate derivative. It’s always either the default or empty if the fallback is set to empty.

This makes me think there’s something wrong with my breakpoints.yml e.g. syntax, media queries, etc. So, I’ve tried about a zillion permutations without success.

I am able to get this working if instead of using the Responsive Image module at all, I manually do:

<picture>
    <source media="(max-width:900px)" srcset="{{ heroCol2ImagePath|image_style('pmp_hero_c2_phone') }}">
    <source media="(max-width:1024px)" srcset="{{ heroCol2ImagePath|image_style('pmp_hero_c2_tablet') }}">
    <source media="(min-width:1025px)" srcset="{{ heroCol2ImagePath|image_style('pmp_hero_c2_desktop') }}">
    <img class="pmp-vtwo-hero-image" src="{{ file_url(heroCol2ImagePath) }}" alt="Flowers" style="width:auto;">
</picture>

But, I don’t know how to then use the WebP module with this approach.

If somebody out there is able to point out what bone-head mistake I’m making, you’d forever have my gratitude.

networking – Attempting to drop packets to simulate a network failure

I have a switch running Linux with multiple devices on it.
I’m attempting to simulate a network outage on one of the devices.

I’ve attempted to drop the packets with both netem and iptables using either one of the commands:

tc qdisc add dev <interface> root netem loss 100%

or

iptables -A INPUT -i <interface> -p all -j DROP

However, the device stays connected.

Any ideas?

Attempting to load Laravel project in a VPS with Plesk Git and getting 404

Here are my steps:
I used Plesk git to pull a repository for my project.
The files are found in httpdocs/laravel project here

hosting settings -> Document root = httpdocs/public

I ran composer and installed all necessary dependancy and also setup .env with correct database settings.

PHP is 7.4.16 run PHP as FPM application served by Apache

.htaccess file found in public/.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - (E=HTTP_AUTHORIZATION:%{HTTP:Authorization})

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 (L,R=301)

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php (L)
</IfModule>

When I check my site I get a 404 error being served up by the laravel project. Any idea what I’m doing wrong?

Error attempting to drop a photo from Image Capture into Photos

macOS 11.2.3 (20D91)
Photos Version 6.0 (330.0.150)
Image Capture Version 8.0 (1106)

When I attempt to drag and drop a photo from Image Capture into Photos I receive the
The application “Photos.app” can’t be opened.
-10813

Image Capture Message window

Attempting to create LOD variations of unity prefab

Hey guys I am attempting to make some LOD variants of my prefab and am getting a strange result. I am using unity fbx exporter and blender version 2.80.7. Here is the model before and after but even without altering the model two of the plants look completely flat on import. Is there some common cause for this or could this be just the model?

Regular Prefab

After

code – Help with subscripts. Attempting to compute Salamin and brent equation for finding pi

You can implement recursions almost in the same way you have specified them:

Clear(a, b, c, s, p);
a(0) = 1.; b(0) = 1/Sqrt(2); c(0) = 1/2; s(0) = c(0);
a(k_) := a(k) = (a(k - 1) + b(k - 1))/2;
b(k_) := b(k) = Sqrt(a(k - 1) b(k - 1));
c(k_) := c(k) = a(k)^2 - b(k)^2;
s(k_) := s(k) = s(k - 1) - 2^k c(k);
p(k_) := p(k) = 2 a(k)^2/s(k);

The first 10 terms:

p(#) & /@ Range(10)

{3.18767, 3.14168, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159}

It seems to converge very quickly! If you want to retain exact expressions (instead of machine precision), use a(0)=1 (instead of a(0)=1.).

8 – Attempting to merge in an array of items into Twig classes

I have a Twig template where I’d like to merge in an array of items as classes. So far I have this code:

{% set classes = (
  'media',
  'media--type-' ~ media.bundle()|clean_class,
  not media.isPublished() ? 'media--unpublished',
  view_mode ? 'media--view-mode-' ~ view_mode|clean_class,
) %}


 {% for item in content.field_category | children(true) %}
   {% set classes = classes|merge(item) %}
 {% endfor %}

<section{{ attributes.addClass(classes) }}>

etc...

Note that {% for item in content.field_category | children(true) %} is using Twig Tweak.

In this case for example, item represents term values for each item in plain text as:

Nature 
Travel
Architecture

and then with <section{{ attributes.addClass(classes) }}>, I’d like the set classes as well as my custom classes to all be merged together. However, I am getting an error:

Notice: Array to string conversion in DrupalCoreTemplateAttributeArray->__toString() (line 73 of core/lib/Drupal/Core/Template/AttributeArray.php).

So this tells me, I did not merge the array of items properly but I am lost after this, not sure how to fix it. My guess is, I need to do this without a for loop somehow?

blender – Attempting to remove extra “edges” from truncated icosahedron lead to excessively global concequences

I need a truncated icosahedron. Blender lets me do that with add -> mesh -> math function -> regular solid (assuming the extra plugin is installed.) So far so good. However, the mesh that is created does not use ngons. This means that each hexagon or pentagon face is cut by an unusable edge approximately through the middle. These extra “lines” destroy the visual symmetry I need for the wireframe.

I have tried deleting the extra edges. This results in the in the removal of far more than just the offending edge. It blows a huge hole in the whole object. I have tried merging the two faces (which compose the pentagon or hexagon) into an ngon. Somehow this again ends up doing far more than just merge the two parts of the face.

No matter what I try I get unintended effects that are far to global. I have also considered drawing fresh lines over only the desired edges. I cannot figure out how to do this either. I have also extracted the faces and edges with python, but those are too cumbersome to edit… and then what?

How do I get a nice clean geometric wire Frame without distracting extra edges?