Friday 30 July 2021

How to rebase and merge in master or other branch in git?

Simple way to rebase and merge the branch into other branch/master in git is going to explain by some steps:

1. Go to your Branch. // which you want to merge... in Git bash

2. git rebase master_branch_name // underline word will be your master or other branch where you want to upload.

This rebase will push your commits to top of the master/other branch..

3. Then pull and push the code by git desktop software.

4. Then go to the master or head branch (git checkout branch name)

5. git merge your_branchname  // underline word will be your lower branch name.


Note: If have any suggestions or issue regarding 'How to rebase and merge in master or other branch in git?' then you can ask by comments. 

How to point the branch changes to Acquia by Git?

Simple way to push the branch changes to Acquia Box(environment):
1. Go to the Acquia account click on box(there you want to point the branch changes) and follow the image instructions:


afterthat it will automatically sync your files related changes to box.

2. Go to the project folder or docroot and open cmd terminal and run the command.
drush sa  // for print all project aliases or environments/boxes of acquia
Then
Take the alias of box where you want to point the config changes..
drush @alias cim  //for point config changes

3 If you want to create the reset password for new or already exist box link:
drush @alias uli  //for reset password link

Note: If have any suggestions or issue regarding 'How to point the branch changes to Acquia by Git?' then you can ask by comments. 

Thursday 8 July 2021

How to convert image in webp format programmatically?

We are giving an example for convert normal image to webp image format programmatically. Here all code/examples are already used in our projects.

Example:

use Drupal\image\Entity\ImageStyle;
use Drupal\media\Entity\Media;
use Drupal\responsive_background_image\ResponsiveBackgroundImage;

if ($tab_img = $tab_entity->get('field_image')->getValue()) {

          $tab_img = array_shift($tab_img);

          $mid = $tab_img['target_id'];

          $media = Media::load($mid);

          $fid = $media->field_image->target_id; 

          // if you want simple image url..

          $style = 'max_160w';  //pass image format

          $url = content_asset_image_url($fid, $style);

          $variables['tab_titles'][$tab['target_id']]['icon'] = $url;

          // if you want image convert into webp image format..

          $file = File::load($fid);

          $uri = $file->getFileUri();

          $variables['tab_titles'][$tab['target_id']]['icon']  = [

            '#theme' => 'responsive_image',

            '#responsive_image_style_id' => 'responsive_asset_300x300',  //pass responsive image format

            '#alt' => 'Resource Content Asset',

            '#uri' => $uri,

            // Add `#attributes` key with alt text.

            '#attributes' => [

              'data-lazy'=> TRUE,

            ],

          ];

        }

 // Content Asset function to get Image URL

function content_asset_image_url($file_id, $style_choice) {

  $file = File::load($file_id);

  $image_uri = $file->getFileUri();

  $style = ImageStyle::load($style_choice);

  $url = $style->buildUrl($image_uri);

  return $url;

}


Note: If have any suggestions or issue regarding 'How to convert image in webp format programmatically?' then you can ask by comments. 

How to resolve max execution time error in drupal ?

When you found error regarding 'max_execution_time' exceed, then you can follow steps for resolve this error: Steps:   You can put t...