Why does this custom code not generate an image?

Created on 31 January 2023, almost 2 years ago
Updated 20 November 2023, about 1 year ago

The image style don't generate the image in the folder web/sites/default/files/styles/resize468/... and in twig $url return the url but the image is not existe.

function theme_preprocess_block(&$variables) {
  if($variables['plugin_id'] == "inline_block:image")
  {
    $block = $variables['content']['#block_content'];
    $uri = $block->get('field_image')->entity->getFileUri();
    $url = ImageStyle::load('resize468')->buildUrl($uri);
    $variables['image_url'] = $url;
  }
}
💬 Support request
Status

Closed: outdated

Version

9.5

Component
Image module 

Last updated 4 days ago

Created by

🇲🇬Madagascar Dev-man

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Dev-man
  • Status changed to RTBC almost 2 years ago
  • Status changed to Active almost 2 years ago
  • Status changed to Postponed: needs info over 1 year ago
  • 🇲🇬Madagascar Dev-man

    The resolution of the problem is in environnement of dev and need many extension php for ImageStyle work correctly and the error is not reporting to a log message of Drupal send extension is missing.
    This is my example of DockerFile Php.

    FROM php:8.1.16-apache
    
    RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
    
    RUN apt-get update \
    && apt-get install -y --no-install-recommends \
     locales apt-utils git libicu-dev g++ libpng-dev \
     libxml2-dev libzip-dev libonig-dev libxslt-dev \
     libpng-dev libjpeg-dev build-essential \
     libfreetype6-dev libpq-dev libjpeg62-turbo-dev \
     libwebp-dev vim nano libmcrypt-dev libmagickwand-dev --no-install-recommends;
    
    RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen && \
    locale-gen
    
    RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls && \
    mv composer.phar /usr/local/bin/composer
    
    RUN docker-php-ext-configure intl
    RUN docker-php-ext-install pcntl
    RUN docker-php-ext-install pdo pdo_mysql gd opcache intl zip calendar dom mbstring zip gd xsl
    RUN docker-php-ext-configure gd --enable-gd --with-jpeg --with-freetype
    RUN pecl install apcu mcrypt-1.0.2 && docker-php-ext-enable apcu
    RUN composer require "drush/drush"
    RUN set -e; \
        docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype; \
        docker-php-ext-install -j$(nproc) gd;
    RUN pecl install imagick
    RUN pecl install xdebug && docker-php-ext-enable xdebug
    RUN docker-php-ext-enable imagick
    RUN curl https://drupalconsole.com/installer -L -o drupal.phar
    RUN mv drupal.phar /usr/local/bin/drupal && chmod +x /usr/local/bin/drupal
    #RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
    
    # Permissions
    RUN chown -R root:www-data /var/www
    RUN chmod u+rwx,g+rx,o+rx /var/www
    RUN find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} +
    RUN find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +
    
    WORKDIR /var/www
    RUN a2enmod rewrite
    RUN a2enmod ssl
    
    RUN usermod -u 1000 www-data
    
    RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
    #RUN mv php/ /var/www/php
    
    WORKDIR /var/www/
    
    EXPOSE 80
    
  • Status changed to Closed: outdated about 1 year ago
  • I am closing this issue due to inactivity. Reopen it as necessary.

Production build 0.71.5 2024