Setting up alternative texts for 1C-Bitrix images

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    565
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    657
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    980

Setting Up Alternative Text for Images in 1C-Bitrix

Empty alt is not just an accessibility issue. It's an SEO loss: Google uses alt-text as a text signal for image ranking in search. An online store with thousands of products where alt is either empty or equals "image.jpg" — that's thousands of missed entry points from Google Images. In Bitrix, alt-texts don't fill automatically anywhere in standard components.

Where Alt is Stored in Infoblock

Bitrix stores image alt-text in the b_file table — DESCRIPTION field. This field is filled in admin when uploading a file. Also for F-type properties, there's a DESCRIPTION field in b_iblock_element_property — this is the caption for a specific image use in an element, independent of the b_file caption.

Priority when displaying: if element property has DESCRIPTION — use it; if not — take DESCRIPTION from b_file; if empty there too — generate from product name.

In component template:

$fileId = $arResult['DETAIL_PICTURE']['ID'];
$fileData = \CFile::GetFileArray($fileId);

$alt = '';
// Priority 1: element property description
if (!empty($arResult['PROPERTIES']['DETAIL_PICTURE']['DESCRIPTION'])) {
    $alt = $arResult['PROPERTIES']['DETAIL_PICTURE']['DESCRIPTION'];
}
// Priority 2: file description
elseif (!empty($fileData['DESCRIPTION'])) {
    $alt = $fileData['DESCRIPTION'];
}
// Priority 3: product name
else {
    $alt = $arResult['NAME'];
}

$alt = htmlspecialcharsEx($alt);

Bulk Filling Alt for Existing Products

If store ran for years with thousands of images without alt — need a bulk fill script. Logic: go through all infoblock elements, take DETAIL_PICTURE and MORE_PHOTO, check DESCRIPTION in b_file, if empty — fill from element name.

Script runs via Bitrix agent or CLI:

$res = \CIBlockElement::GetList(
    ['ID' => 'ASC'],
    ['IBLOCK_ID' => CATALOG_IBLOCK_ID],
    false,
    ['nTopCount' => 100, 'iNumPage' => $page],
    ['ID', 'NAME', 'DETAIL_PICTURE']
);

while ($el = $res->GetNextElement()) {
    $fields = $el->GetFields();
    if (empty($fields['DETAIL_PICTURE'])) continue;

    $fileId = $fields['DETAIL_PICTURE'];
    $fileData = \CFile::GetFileArray($fileId);

    if (empty($fileData['DESCRIPTION'])) {
        $DB->Query("UPDATE b_file SET DESCRIPTION = '" .
            $DB->ForSql($fields['NAME']) .
            "' WHERE ID = " . (int)$fileId);
    }
}

Direct UPDATE to b_file is faster than CFile::Update() — it clears cache for each file separately.

Alt for Images in News and Article Infoblocks

For images inserted via TinyMCE in DETAIL_TEXT field, alt is filled directly in editor. Problem: if content managers ignore the alt field in insert dialog, images get empty alt="" or alt="image".

Solution at editor level: in TinyMCE settings (config file in template) add alt field requirement via custom plugin or form insertion validation. Another approach — post-process HTML on save via OnBeforeIBlockElementUpdate handler: parse DETAIL_TEXT with DOMDocument, find <img> without alt and substitute article title.

Decorative Images

Icons, dividers, and decorative background elements should have empty alt="" — an intentionally empty attribute signaling screen reader to ignore the image. Error — to not specify alt at all (WCAG 1.1.1 violation) or specify descriptive text for decoration (noise for assistive technology). In Bitrix templates, icons often render via <img> — should replace them with inline SVG with aria-hidden="true" or add explicit alt="".