How to resize Image in Magento 2?
I want to resized image of subcategory. for that,
I added this code in .phtml file.I'm getting wrong path for image
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$catId = 3; //Parent Category ID
$subCategory = $objectManager->create('MagentoCatalogModelCategory')->load($catId);
$subCats = $subCategory->getChildrenCategories();
$_helper = $this->helper('MagentoCatalogHelperOutput');
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$count = 0;
?>
<div class="container homecat">
<div class="row">
<?php
foreach ($subCats as $subcat) {
$_category = $objectManager->create('MagentoCatalogModelCategory')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
$_imgHtml = '';
$subcaturl = $_imagehelper->init($_category, 'image')->keepAspectRatio(TRUE)
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->resize('256','128')
->getUrl();
echo $subcaturl ."<br/>";
$_imgHtml = '<img src="' . $subcaturl . '" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
echo $_imgHtml;
} ?>
</div>
</div>
I am getting
http://Hostname/als2/pub/static/version1549014696/frontend/Theme/Name/en_US/Magento_Catalog/images/product/placeholder/.jpg
magento2 image image-resizing sub-categories
add a comment |
I want to resized image of subcategory. for that,
I added this code in .phtml file.I'm getting wrong path for image
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$catId = 3; //Parent Category ID
$subCategory = $objectManager->create('MagentoCatalogModelCategory')->load($catId);
$subCats = $subCategory->getChildrenCategories();
$_helper = $this->helper('MagentoCatalogHelperOutput');
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$count = 0;
?>
<div class="container homecat">
<div class="row">
<?php
foreach ($subCats as $subcat) {
$_category = $objectManager->create('MagentoCatalogModelCategory')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
$_imgHtml = '';
$subcaturl = $_imagehelper->init($_category, 'image')->keepAspectRatio(TRUE)
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->resize('256','128')
->getUrl();
echo $subcaturl ."<br/>";
$_imgHtml = '<img src="' . $subcaturl . '" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
echo $_imgHtml;
} ?>
</div>
</div>
I am getting
http://Hostname/als2/pub/static/version1549014696/frontend/Theme/Name/en_US/Magento_Catalog/images/product/placeholder/.jpg
magento2 image image-resizing sub-categories
Bhakti, Please check my updated ans in detailed way.
– Aasim Goriya
2 days ago
thanks, I found the solution @AasimGoriya
– Bhakti Thakkar
2 days ago
add a comment |
I want to resized image of subcategory. for that,
I added this code in .phtml file.I'm getting wrong path for image
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$catId = 3; //Parent Category ID
$subCategory = $objectManager->create('MagentoCatalogModelCategory')->load($catId);
$subCats = $subCategory->getChildrenCategories();
$_helper = $this->helper('MagentoCatalogHelperOutput');
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$count = 0;
?>
<div class="container homecat">
<div class="row">
<?php
foreach ($subCats as $subcat) {
$_category = $objectManager->create('MagentoCatalogModelCategory')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
$_imgHtml = '';
$subcaturl = $_imagehelper->init($_category, 'image')->keepAspectRatio(TRUE)
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->resize('256','128')
->getUrl();
echo $subcaturl ."<br/>";
$_imgHtml = '<img src="' . $subcaturl . '" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
echo $_imgHtml;
} ?>
</div>
</div>
I am getting
http://Hostname/als2/pub/static/version1549014696/frontend/Theme/Name/en_US/Magento_Catalog/images/product/placeholder/.jpg
magento2 image image-resizing sub-categories
I want to resized image of subcategory. for that,
I added this code in .phtml file.I'm getting wrong path for image
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$catId = 3; //Parent Category ID
$subCategory = $objectManager->create('MagentoCatalogModelCategory')->load($catId);
$subCats = $subCategory->getChildrenCategories();
$_helper = $this->helper('MagentoCatalogHelperOutput');
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$count = 0;
?>
<div class="container homecat">
<div class="row">
<?php
foreach ($subCats as $subcat) {
$_category = $objectManager->create('MagentoCatalogModelCategory')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
$_imgHtml = '';
$subcaturl = $_imagehelper->init($_category, 'image')->keepAspectRatio(TRUE)
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->resize('256','128')
->getUrl();
echo $subcaturl ."<br/>";
$_imgHtml = '<img src="' . $subcaturl . '" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
echo $_imgHtml;
} ?>
</div>
</div>
I am getting
http://Hostname/als2/pub/static/version1549014696/frontend/Theme/Name/en_US/Magento_Catalog/images/product/placeholder/.jpg
magento2 image image-resizing sub-categories
magento2 image image-resizing sub-categories
edited 10 mins ago
Ketan Borada
256736
256736
asked 2 days ago
Bhakti ThakkarBhakti Thakkar
49914
49914
Bhakti, Please check my updated ans in detailed way.
– Aasim Goriya
2 days ago
thanks, I found the solution @AasimGoriya
– Bhakti Thakkar
2 days ago
add a comment |
Bhakti, Please check my updated ans in detailed way.
– Aasim Goriya
2 days ago
thanks, I found the solution @AasimGoriya
– Bhakti Thakkar
2 days ago
Bhakti, Please check my updated ans in detailed way.
– Aasim Goriya
2 days ago
Bhakti, Please check my updated ans in detailed way.
– Aasim Goriya
2 days ago
thanks, I found the solution @AasimGoriya
– Bhakti Thakkar
2 days ago
thanks, I found the solution @AasimGoriya
– Bhakti Thakkar
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
Create resize image by passing image URL
create Block file
appcodeKetanResizeHelperImage.php
pass url and dimension
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace KetanResizeHelper;
use MagentoFrameworkFilesystem;
use MagentoFrameworkUrl;
use MagentoFrameworkAppHelperAbstractHelper;
use MagentoFrameworkAppFilesystemDirectoryList;
class Image extends MagentoFrameworkAppHelperAbstractHelper {
protected $scopeConfig;
protected $storeManager;
protected $messageManager;
protected $_response;
protected $_resourceConfig;
protected $_responseFactory;
protected $_url;
protected $_filesystem;
protected $_directory;
protected $_imageFactory;
public function __construct(
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager,
MagentoFrameworkMessageManagerInterface $messageManager,
MagentoFrameworkAppResponseInterface $response,
MagentoFrameworkAppConfigStorageWriterInterface $resourceConfig,
MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url,
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkImageAdapterFactory $imageFactory
)
{
$this->scopeConfig = $scopeConfig;
$this->_storeManager=$storeManager;
$this->messageManager=$messageManager;
$this->_response=$response;
$this->_resourceConfig=$resourceConfig;
$this->_responseFactory = $responseFactory;
$this->_url = $url;
$this->_filesystem = $filesystem;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
}
public function imageResize(
$src,
$width=35,
$height=35,
$dir='resize/'
){
if (!@getimagesize($src)) {
$src = $this->_storeManager->getStore()->getBaseUrl().'pub/media/catalog/product/placeholder/'.$this->scopeConfig->getValue('catalog/placeholder/small_image_placeholder',MagentoStoreModelScopeInterface::SCOPE_STORE);
}
$absPath = $src;
$imageResized = $this->_filesystem
->getDirectoryRead(DirectoryList::MEDIA)
->getAbsolutePath($dir).
$this->getNewDirectoryImage($src);
$imageResize = $this->_imageFactory->create();
$imageResize->open($absPath);
$imageResize->backgroundColor([255, 255, 255]);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(true);
$imageResize->keepAspectRatio(true);
$imageResize->resize($width,$height);
$dest = $imageResized ;
$imageResize->save($dest);
$resizedURL= $this->_storeManager->getStore()
->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).
$dir.$this->getNewDirectoryImage($src);
return $resizedURL;
}
public function getNewDirectoryImage($src){
$segments = array_reverse(explode('/',$src));
$first_dir = substr($segments[0],0,1);
$second_dir = substr($segments[0],1,1);
return 'cache/'.$first_dir.'/'.$second_dir.'/'.$segments[0];
}
}
In your phtml
file
<?php foreach ($subcats as $subcat) {
$_imgUrl = $subcat->getImageUrl(); ?>
<img src="<?php echo $this->helper('KetanresizeHelperImage')->imageResize($_imgUrl,'256','128','subtcat/'); ?>">
<?php } ?>
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
be sure are you passing category image url in$_imgUrl
otherwise it will take place holder image
– Ketan Borada
2 days ago
add a comment |
Please try this code for resized any images.
Using $objectManager :
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$directory = $objectManager->get('MagentoFrameworkFilesystemDirectoryList');
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$fileSystem = $objectManager->get('MagentoFrameworkFilesystem');
$absolutePath = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$subcat->getUrl();
$imageResized = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$subcat->getUrl();
//create image factory...
$imageResize = $objectManager->create('MagentoFrameworkImageAdapterFactory');
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
echo $resizedURL;
Using Helper :
<?php
namespace VendorModuleHelper;
use MagentoStoreModelStoreManagerInterface;
class Imageresize extends MagentoFrameworkAppHelperAbstractHelper
{
protected $_filesystem ;
protected $_imageFactory;
protected $_storeManager;
protected $_objectManager;
public function __construct(
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkObjectManagerInterface $objectManager,
StoreManagerInterface $storeManager,
MagentoFrameworkImageAdapterFactory $imageFactory
) {
$this->_filesystem = $filesystem;
$this->_imageFactory = $imageFactory;
$this->_objectManager = $objectManager;
$this->_storeManager = $storeManager;
}
// pass imagename, width and height
public function resize($image, $width = null, $height = null)
{
$absolutePath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$image;
$imageResized = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$image;
//create image factory...
$imageResize = $this->_imageFactory->create();
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $this->_storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
return $resizedURL;
}
}
?>
And then add following code in your .phtml
<?php $imgResized = $this->helper('VendorModuleHelperImageresize')->resize($subcaturl,277,180); ?>
<a href="<?php echo $br['link']; ?>"><img src="<?php echo $imgResized; ?>" /></a>
Please check and let me know if any issue.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f260123%2fhow-to-resize-image-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Create resize image by passing image URL
create Block file
appcodeKetanResizeHelperImage.php
pass url and dimension
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace KetanResizeHelper;
use MagentoFrameworkFilesystem;
use MagentoFrameworkUrl;
use MagentoFrameworkAppHelperAbstractHelper;
use MagentoFrameworkAppFilesystemDirectoryList;
class Image extends MagentoFrameworkAppHelperAbstractHelper {
protected $scopeConfig;
protected $storeManager;
protected $messageManager;
protected $_response;
protected $_resourceConfig;
protected $_responseFactory;
protected $_url;
protected $_filesystem;
protected $_directory;
protected $_imageFactory;
public function __construct(
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager,
MagentoFrameworkMessageManagerInterface $messageManager,
MagentoFrameworkAppResponseInterface $response,
MagentoFrameworkAppConfigStorageWriterInterface $resourceConfig,
MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url,
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkImageAdapterFactory $imageFactory
)
{
$this->scopeConfig = $scopeConfig;
$this->_storeManager=$storeManager;
$this->messageManager=$messageManager;
$this->_response=$response;
$this->_resourceConfig=$resourceConfig;
$this->_responseFactory = $responseFactory;
$this->_url = $url;
$this->_filesystem = $filesystem;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
}
public function imageResize(
$src,
$width=35,
$height=35,
$dir='resize/'
){
if (!@getimagesize($src)) {
$src = $this->_storeManager->getStore()->getBaseUrl().'pub/media/catalog/product/placeholder/'.$this->scopeConfig->getValue('catalog/placeholder/small_image_placeholder',MagentoStoreModelScopeInterface::SCOPE_STORE);
}
$absPath = $src;
$imageResized = $this->_filesystem
->getDirectoryRead(DirectoryList::MEDIA)
->getAbsolutePath($dir).
$this->getNewDirectoryImage($src);
$imageResize = $this->_imageFactory->create();
$imageResize->open($absPath);
$imageResize->backgroundColor([255, 255, 255]);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(true);
$imageResize->keepAspectRatio(true);
$imageResize->resize($width,$height);
$dest = $imageResized ;
$imageResize->save($dest);
$resizedURL= $this->_storeManager->getStore()
->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).
$dir.$this->getNewDirectoryImage($src);
return $resizedURL;
}
public function getNewDirectoryImage($src){
$segments = array_reverse(explode('/',$src));
$first_dir = substr($segments[0],0,1);
$second_dir = substr($segments[0],1,1);
return 'cache/'.$first_dir.'/'.$second_dir.'/'.$segments[0];
}
}
In your phtml
file
<?php foreach ($subcats as $subcat) {
$_imgUrl = $subcat->getImageUrl(); ?>
<img src="<?php echo $this->helper('KetanresizeHelperImage')->imageResize($_imgUrl,'256','128','subtcat/'); ?>">
<?php } ?>
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
be sure are you passing category image url in$_imgUrl
otherwise it will take place holder image
– Ketan Borada
2 days ago
add a comment |
Create resize image by passing image URL
create Block file
appcodeKetanResizeHelperImage.php
pass url and dimension
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace KetanResizeHelper;
use MagentoFrameworkFilesystem;
use MagentoFrameworkUrl;
use MagentoFrameworkAppHelperAbstractHelper;
use MagentoFrameworkAppFilesystemDirectoryList;
class Image extends MagentoFrameworkAppHelperAbstractHelper {
protected $scopeConfig;
protected $storeManager;
protected $messageManager;
protected $_response;
protected $_resourceConfig;
protected $_responseFactory;
protected $_url;
protected $_filesystem;
protected $_directory;
protected $_imageFactory;
public function __construct(
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager,
MagentoFrameworkMessageManagerInterface $messageManager,
MagentoFrameworkAppResponseInterface $response,
MagentoFrameworkAppConfigStorageWriterInterface $resourceConfig,
MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url,
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkImageAdapterFactory $imageFactory
)
{
$this->scopeConfig = $scopeConfig;
$this->_storeManager=$storeManager;
$this->messageManager=$messageManager;
$this->_response=$response;
$this->_resourceConfig=$resourceConfig;
$this->_responseFactory = $responseFactory;
$this->_url = $url;
$this->_filesystem = $filesystem;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
}
public function imageResize(
$src,
$width=35,
$height=35,
$dir='resize/'
){
if (!@getimagesize($src)) {
$src = $this->_storeManager->getStore()->getBaseUrl().'pub/media/catalog/product/placeholder/'.$this->scopeConfig->getValue('catalog/placeholder/small_image_placeholder',MagentoStoreModelScopeInterface::SCOPE_STORE);
}
$absPath = $src;
$imageResized = $this->_filesystem
->getDirectoryRead(DirectoryList::MEDIA)
->getAbsolutePath($dir).
$this->getNewDirectoryImage($src);
$imageResize = $this->_imageFactory->create();
$imageResize->open($absPath);
$imageResize->backgroundColor([255, 255, 255]);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(true);
$imageResize->keepAspectRatio(true);
$imageResize->resize($width,$height);
$dest = $imageResized ;
$imageResize->save($dest);
$resizedURL= $this->_storeManager->getStore()
->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).
$dir.$this->getNewDirectoryImage($src);
return $resizedURL;
}
public function getNewDirectoryImage($src){
$segments = array_reverse(explode('/',$src));
$first_dir = substr($segments[0],0,1);
$second_dir = substr($segments[0],1,1);
return 'cache/'.$first_dir.'/'.$second_dir.'/'.$segments[0];
}
}
In your phtml
file
<?php foreach ($subcats as $subcat) {
$_imgUrl = $subcat->getImageUrl(); ?>
<img src="<?php echo $this->helper('KetanresizeHelperImage')->imageResize($_imgUrl,'256','128','subtcat/'); ?>">
<?php } ?>
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
be sure are you passing category image url in$_imgUrl
otherwise it will take place holder image
– Ketan Borada
2 days ago
add a comment |
Create resize image by passing image URL
create Block file
appcodeKetanResizeHelperImage.php
pass url and dimension
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace KetanResizeHelper;
use MagentoFrameworkFilesystem;
use MagentoFrameworkUrl;
use MagentoFrameworkAppHelperAbstractHelper;
use MagentoFrameworkAppFilesystemDirectoryList;
class Image extends MagentoFrameworkAppHelperAbstractHelper {
protected $scopeConfig;
protected $storeManager;
protected $messageManager;
protected $_response;
protected $_resourceConfig;
protected $_responseFactory;
protected $_url;
protected $_filesystem;
protected $_directory;
protected $_imageFactory;
public function __construct(
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager,
MagentoFrameworkMessageManagerInterface $messageManager,
MagentoFrameworkAppResponseInterface $response,
MagentoFrameworkAppConfigStorageWriterInterface $resourceConfig,
MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url,
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkImageAdapterFactory $imageFactory
)
{
$this->scopeConfig = $scopeConfig;
$this->_storeManager=$storeManager;
$this->messageManager=$messageManager;
$this->_response=$response;
$this->_resourceConfig=$resourceConfig;
$this->_responseFactory = $responseFactory;
$this->_url = $url;
$this->_filesystem = $filesystem;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
}
public function imageResize(
$src,
$width=35,
$height=35,
$dir='resize/'
){
if (!@getimagesize($src)) {
$src = $this->_storeManager->getStore()->getBaseUrl().'pub/media/catalog/product/placeholder/'.$this->scopeConfig->getValue('catalog/placeholder/small_image_placeholder',MagentoStoreModelScopeInterface::SCOPE_STORE);
}
$absPath = $src;
$imageResized = $this->_filesystem
->getDirectoryRead(DirectoryList::MEDIA)
->getAbsolutePath($dir).
$this->getNewDirectoryImage($src);
$imageResize = $this->_imageFactory->create();
$imageResize->open($absPath);
$imageResize->backgroundColor([255, 255, 255]);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(true);
$imageResize->keepAspectRatio(true);
$imageResize->resize($width,$height);
$dest = $imageResized ;
$imageResize->save($dest);
$resizedURL= $this->_storeManager->getStore()
->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).
$dir.$this->getNewDirectoryImage($src);
return $resizedURL;
}
public function getNewDirectoryImage($src){
$segments = array_reverse(explode('/',$src));
$first_dir = substr($segments[0],0,1);
$second_dir = substr($segments[0],1,1);
return 'cache/'.$first_dir.'/'.$second_dir.'/'.$segments[0];
}
}
In your phtml
file
<?php foreach ($subcats as $subcat) {
$_imgUrl = $subcat->getImageUrl(); ?>
<img src="<?php echo $this->helper('KetanresizeHelperImage')->imageResize($_imgUrl,'256','128','subtcat/'); ?>">
<?php } ?>
Create resize image by passing image URL
create Block file
appcodeKetanResizeHelperImage.php
pass url and dimension
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace KetanResizeHelper;
use MagentoFrameworkFilesystem;
use MagentoFrameworkUrl;
use MagentoFrameworkAppHelperAbstractHelper;
use MagentoFrameworkAppFilesystemDirectoryList;
class Image extends MagentoFrameworkAppHelperAbstractHelper {
protected $scopeConfig;
protected $storeManager;
protected $messageManager;
protected $_response;
protected $_resourceConfig;
protected $_responseFactory;
protected $_url;
protected $_filesystem;
protected $_directory;
protected $_imageFactory;
public function __construct(
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager,
MagentoFrameworkMessageManagerInterface $messageManager,
MagentoFrameworkAppResponseInterface $response,
MagentoFrameworkAppConfigStorageWriterInterface $resourceConfig,
MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url,
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkImageAdapterFactory $imageFactory
)
{
$this->scopeConfig = $scopeConfig;
$this->_storeManager=$storeManager;
$this->messageManager=$messageManager;
$this->_response=$response;
$this->_resourceConfig=$resourceConfig;
$this->_responseFactory = $responseFactory;
$this->_url = $url;
$this->_filesystem = $filesystem;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
}
public function imageResize(
$src,
$width=35,
$height=35,
$dir='resize/'
){
if (!@getimagesize($src)) {
$src = $this->_storeManager->getStore()->getBaseUrl().'pub/media/catalog/product/placeholder/'.$this->scopeConfig->getValue('catalog/placeholder/small_image_placeholder',MagentoStoreModelScopeInterface::SCOPE_STORE);
}
$absPath = $src;
$imageResized = $this->_filesystem
->getDirectoryRead(DirectoryList::MEDIA)
->getAbsolutePath($dir).
$this->getNewDirectoryImage($src);
$imageResize = $this->_imageFactory->create();
$imageResize->open($absPath);
$imageResize->backgroundColor([255, 255, 255]);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(true);
$imageResize->keepAspectRatio(true);
$imageResize->resize($width,$height);
$dest = $imageResized ;
$imageResize->save($dest);
$resizedURL= $this->_storeManager->getStore()
->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).
$dir.$this->getNewDirectoryImage($src);
return $resizedURL;
}
public function getNewDirectoryImage($src){
$segments = array_reverse(explode('/',$src));
$first_dir = substr($segments[0],0,1);
$second_dir = substr($segments[0],1,1);
return 'cache/'.$first_dir.'/'.$second_dir.'/'.$segments[0];
}
}
In your phtml
file
<?php foreach ($subcats as $subcat) {
$_imgUrl = $subcat->getImageUrl(); ?>
<img src="<?php echo $this->helper('KetanresizeHelperImage')->imageResize($_imgUrl,'256','128','subtcat/'); ?>">
<?php } ?>
answered 2 days ago
Ketan BoradaKetan Borada
256736
256736
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
be sure are you passing category image url in$_imgUrl
otherwise it will take place holder image
– Ketan Borada
2 days ago
add a comment |
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
be sure are you passing category image url in$_imgUrl
otherwise it will take place holder image
– Ketan Borada
2 days ago
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
getting @Error filtering template: Warning: getimagesize(192.168.1.122/als2/pub/media/catalog/product/placeholder): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in D:xampphtdocsals2vendormagentoframeworkImageAdapterAbstractAdapter.php on line 304
– Bhakti Thakkar
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
upload place holder image in admin small_image_placeholder prntscr.com/mf6jlv f there is no image it will take from there
– Ketan Borada
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
I got resized img of placeholder but I want subcategory image
– Bhakti Thakkar
2 days ago
be sure are you passing category image url in
$_imgUrl
otherwise it will take place holder image– Ketan Borada
2 days ago
be sure are you passing category image url in
$_imgUrl
otherwise it will take place holder image– Ketan Borada
2 days ago
add a comment |
Please try this code for resized any images.
Using $objectManager :
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$directory = $objectManager->get('MagentoFrameworkFilesystemDirectoryList');
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$fileSystem = $objectManager->get('MagentoFrameworkFilesystem');
$absolutePath = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$subcat->getUrl();
$imageResized = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$subcat->getUrl();
//create image factory...
$imageResize = $objectManager->create('MagentoFrameworkImageAdapterFactory');
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
echo $resizedURL;
Using Helper :
<?php
namespace VendorModuleHelper;
use MagentoStoreModelStoreManagerInterface;
class Imageresize extends MagentoFrameworkAppHelperAbstractHelper
{
protected $_filesystem ;
protected $_imageFactory;
protected $_storeManager;
protected $_objectManager;
public function __construct(
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkObjectManagerInterface $objectManager,
StoreManagerInterface $storeManager,
MagentoFrameworkImageAdapterFactory $imageFactory
) {
$this->_filesystem = $filesystem;
$this->_imageFactory = $imageFactory;
$this->_objectManager = $objectManager;
$this->_storeManager = $storeManager;
}
// pass imagename, width and height
public function resize($image, $width = null, $height = null)
{
$absolutePath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$image;
$imageResized = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$image;
//create image factory...
$imageResize = $this->_imageFactory->create();
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $this->_storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
return $resizedURL;
}
}
?>
And then add following code in your .phtml
<?php $imgResized = $this->helper('VendorModuleHelperImageresize')->resize($subcaturl,277,180); ?>
<a href="<?php echo $br['link']; ?>"><img src="<?php echo $imgResized; ?>" /></a>
Please check and let me know if any issue.
add a comment |
Please try this code for resized any images.
Using $objectManager :
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$directory = $objectManager->get('MagentoFrameworkFilesystemDirectoryList');
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$fileSystem = $objectManager->get('MagentoFrameworkFilesystem');
$absolutePath = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$subcat->getUrl();
$imageResized = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$subcat->getUrl();
//create image factory...
$imageResize = $objectManager->create('MagentoFrameworkImageAdapterFactory');
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
echo $resizedURL;
Using Helper :
<?php
namespace VendorModuleHelper;
use MagentoStoreModelStoreManagerInterface;
class Imageresize extends MagentoFrameworkAppHelperAbstractHelper
{
protected $_filesystem ;
protected $_imageFactory;
protected $_storeManager;
protected $_objectManager;
public function __construct(
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkObjectManagerInterface $objectManager,
StoreManagerInterface $storeManager,
MagentoFrameworkImageAdapterFactory $imageFactory
) {
$this->_filesystem = $filesystem;
$this->_imageFactory = $imageFactory;
$this->_objectManager = $objectManager;
$this->_storeManager = $storeManager;
}
// pass imagename, width and height
public function resize($image, $width = null, $height = null)
{
$absolutePath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$image;
$imageResized = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$image;
//create image factory...
$imageResize = $this->_imageFactory->create();
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $this->_storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
return $resizedURL;
}
}
?>
And then add following code in your .phtml
<?php $imgResized = $this->helper('VendorModuleHelperImageresize')->resize($subcaturl,277,180); ?>
<a href="<?php echo $br['link']; ?>"><img src="<?php echo $imgResized; ?>" /></a>
Please check and let me know if any issue.
add a comment |
Please try this code for resized any images.
Using $objectManager :
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$directory = $objectManager->get('MagentoFrameworkFilesystemDirectoryList');
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$fileSystem = $objectManager->get('MagentoFrameworkFilesystem');
$absolutePath = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$subcat->getUrl();
$imageResized = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$subcat->getUrl();
//create image factory...
$imageResize = $objectManager->create('MagentoFrameworkImageAdapterFactory');
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
echo $resizedURL;
Using Helper :
<?php
namespace VendorModuleHelper;
use MagentoStoreModelStoreManagerInterface;
class Imageresize extends MagentoFrameworkAppHelperAbstractHelper
{
protected $_filesystem ;
protected $_imageFactory;
protected $_storeManager;
protected $_objectManager;
public function __construct(
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkObjectManagerInterface $objectManager,
StoreManagerInterface $storeManager,
MagentoFrameworkImageAdapterFactory $imageFactory
) {
$this->_filesystem = $filesystem;
$this->_imageFactory = $imageFactory;
$this->_objectManager = $objectManager;
$this->_storeManager = $storeManager;
}
// pass imagename, width and height
public function resize($image, $width = null, $height = null)
{
$absolutePath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$image;
$imageResized = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$image;
//create image factory...
$imageResize = $this->_imageFactory->create();
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $this->_storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
return $resizedURL;
}
}
?>
And then add following code in your .phtml
<?php $imgResized = $this->helper('VendorModuleHelperImageresize')->resize($subcaturl,277,180); ?>
<a href="<?php echo $br['link']; ?>"><img src="<?php echo $imgResized; ?>" /></a>
Please check and let me know if any issue.
Please try this code for resized any images.
Using $objectManager :
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$directory = $objectManager->get('MagentoFrameworkFilesystemDirectoryList');
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$fileSystem = $objectManager->get('MagentoFrameworkFilesystem');
$absolutePath = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$subcat->getUrl();
$imageResized = $objectManager->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$subcat->getUrl();
//create image factory...
$imageResize = $objectManager->create('MagentoFrameworkImageAdapterFactory');
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
echo $resizedURL;
Using Helper :
<?php
namespace VendorModuleHelper;
use MagentoStoreModelStoreManagerInterface;
class Imageresize extends MagentoFrameworkAppHelperAbstractHelper
{
protected $_filesystem ;
protected $_imageFactory;
protected $_storeManager;
protected $_objectManager;
public function __construct(
MagentoFrameworkFilesystem $filesystem,
MagentoFrameworkObjectManagerInterface $objectManager,
StoreManagerInterface $storeManager,
MagentoFrameworkImageAdapterFactory $imageFactory
) {
$this->_filesystem = $filesystem;
$this->_imageFactory = $imageFactory;
$this->_objectManager = $objectManager;
$this->_storeManager = $storeManager;
}
// pass imagename, width and height
public function resize($image, $width = null, $height = null)
{
$absolutePath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::ROOT)->getAbsolutePath('pub/media/').$image;
$imageResized = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath('resized/'.$width.'/').$image;
//create image factory...
$imageResize = $this->_imageFactory->create();
$imageResize->open($absolutePath);
$imageResize->constrainOnly(TRUE);
$imageResize->keepTransparency(TRUE);
$imageResize->keepFrame(FALSE);
$imageResize->keepAspectRatio(TRUE);
$imageResize->resize($width,$height);
//destination folder
$destination = $imageResized;
//save image
$imageResize->save($destination);
$resizedURL = $this->_storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
return $resizedURL;
}
}
?>
And then add following code in your .phtml
<?php $imgResized = $this->helper('VendorModuleHelperImageresize')->resize($subcaturl,277,180); ?>
<a href="<?php echo $br['link']; ?>"><img src="<?php echo $imgResized; ?>" /></a>
Please check and let me know if any issue.
edited 2 days ago
answered 2 days ago
Aasim GoriyaAasim Goriya
3,3081736
3,3081736
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f260123%2fhow-to-resize-image-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Bhakti, Please check my updated ans in detailed way.
– Aasim Goriya
2 days ago
thanks, I found the solution @AasimGoriya
– Bhakti Thakkar
2 days ago