Skip to main content
Commonmark migration
Source Link

Color & Background

##Color & Background## MagentoMagento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

We can remove the generation noise:

enter image description here

##Custom Font##

Custom Font

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.

##Color & Background## Magento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

We can remove the generation noise:

enter image description here

##Custom Font##

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.

Color & Background

Magento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

We can remove the generation noise:

enter image description here

Custom Font

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.

added 126 characters in body
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

##Color & Background## Magento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

We can remove the generation noise:

enter image description here

##Custom Font##

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.

##Color & Background## Magento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

##Custom Font##

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.

##Color & Background## Magento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

We can remove the generation noise:

enter image description here

##Custom Font##

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.

Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

##Color & Background## Magento builds its Model Captcha which extends from Zend_Captcha_Image class. So, in your case, we should override Magento\Captcha\Model\DefaultModel class.

<preference for="Magento\Captcha\Model\DefaultModel"
            type="Vendor\Module\Model\DefaultModel"/>

We need to override _generateImage method.

protected function _generateImage($id, $word)
{
      ......
      $w     = $this->getWidth();
      $h     = $this->getHeight();
      $fsize = $this->getFontSize();
      ......
}

##Custom Font##

Add new font to the default config:

app/code/Company/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <captcha translate="label">
            <fonts>
                <arial>
                    <label>Arial</label>
                    <path>CustomFont/Arial.ttf</path>
                </arial>
            </fonts>
        </captcha>
    </default>
</config>

Add our custom font: lib/internal/CustomFont/Arial.ttf

enter image description here

Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts() to see more details.