Today, we will discuss how we can get current CMS page id using code. Below is an example. protected $_page ; public function __construct ( ... \Magento\Cms\Model\Page $page , ... array $data = [] ) { parent :: __construct ( $context , $data ); ... $this -> _page = $page ; ... } if ( $this -> _page -> getId ()) { $pageId = $this -> _page -> getId (); } Thank You.!
Below is an example. <? php $_imagehelper = $this -> helper ( 'Magento\Catalog\Helper\Image' ); $productImage = $_imagehelper -> init ( $_product , $image )-> constrainOnly ( FALSE )-> keepAspectRatio ( TRUE )-> keepFrame ( FALSE )-> resize ( 400 )-> getUrl (); ?> <img src=" <? php echo $productImage ; ?> " /> Thank You.!