Image

TsgcHTMLComponent_Image — render a Bootstrap image with shape, responsive sizing, lazy loading and an optional lightbox and caption, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Image

A picture element with Bootstrap styling. Set the source and alt text, pick a shape, toggle responsive and lazy loading, then read the HTML property.

Component class

TsgcHTMLComponent_Image

Renders

Bootstrap 5 image markup

Languages

Delphi, C++ Builder, .NET

Create it, set the source, render it

Assign Src and Alt, pick a Shape, toggle Responsive, LazyLoad and Lightbox, then read HTML — or use the static one-line Build helper.

uses
  sgcHTML_Enums, sgcHTML_Component_Image;

var
  oImg: TsgcHTMLComponent_Image;
begin
  oImg := TsgcHTMLComponent_Image.Create(nil);
  try
    oImg.Src := '/img/team.jpg';
    oImg.Alt := 'Our team';
    oImg.Shape := isRounded;
    oImg.Responsive := True;
    oImg.Lightbox := True;
    oImg.Caption := 'The team at work';

    WebModule.Response := oImg.HTML;   // <img> markup
  finally
    oImg.Free;
  end;
end;

// Or in a single line with the static helper:
Result := TsgcHTMLComponent_Image.Build('/img/team.jpg', 'Our team',
  isRounded, True);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Image.hpp

TsgcHTMLComponent_Image *oImg = new TsgcHTMLComponent_Image(NULL);
try
{
  oImg->Src = "/img/team.jpg";
  oImg->Alt = "Our team";
  oImg->Shape = isRounded;
  oImg->Responsive = true;
  oImg->Lightbox = true;
  oImg->Caption = "The team at work";

  String html = oImg->HTML;   // <img> markup
}
__finally
{
  delete oImg;
}

// Or in a single line with the static helper:
String html = TsgcHTMLComponent_Image::Build("/img/team.jpg", "Our team",
  isRounded, true);
using esegece.sgcWebSockets;

var img = new TsgcHTMLComponent_Image();
img.Src = "/img/team.jpg";
img.Alt = "Our team";
img.Shape = TsgcHTMLImageShape.isRounded;
img.Responsive = true;
img.Lightbox = true;
img.Caption = "The team at work";

string html = img.HTML;   // <img> markup

// Or in a single line with the static helper:
string oneLine = TsgcHTMLComponent_Image.Build("/img/team.jpg", "Our team",
    TsgcHTMLImageShape.isRounded, true);

Key properties & methods

The members you reach for most often.

Source

Src sets the image URL and Alt the accessible alternative text.

Shape

Shape (TsgcHTMLImageShape: isRounded, isCircle, isThumbnail) styles the corners and border.

Sizing

Responsive applies img-fluid so the image scales to its container; Width and Height set explicit dimensions.

Loading

LazyLoad adds loading="lazy" so off-screen images defer until needed.

Extras

Lightbox wraps the image in a link to the full-size source; Caption wraps it in a figure with a caption; ImageID sets the DOM id.

One-line build

Build(aSrc, aAlt, aShape, aResponsive) returns the image HTML in a single static call.

Keep exploring

All sgcHTML ComponentsBrowse the full feature matrix of 60+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.