Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
Oct 16, 2015 2:28 AM UTC

It should be taken care in your CSS making image as background and text as center aligned for that div

3 replies

Level 8
Oct 16, 2015 2:28 AM UTC

The image object has a getSrc() property.  You can switch your code up to utilize it:

<%

    Image image = new Image(resource, "image");

    image.setSelector(".img");

    String text = properties.get("text", "TEXT NA");


%>

    <%= text %>

<div style="background-image: url(<%=image.getSrc() %>);"></div>

Translate
sumit5290
sumit5290Author
Oct 16, 2015 2:28 AM UTC

bsloki wrote...

It should be taken care in your CSS making image as background and text as center aligned for that div

 

<%@include file="/libs/foundation/global.jsp"%>
<%@ page import="com.day.cq.wcm.foundation.Image" %>
<%

    Image image = new Image(resource, "image");

    image.setSelector(".img");

    String text = properties.get("text", "TEXT NA");


%>

    <%= text %>
<%
    image.draw(out);

%>
<%
   image.getDescription().length();
%>

 

 

i m using this code...how to have the css inside it

Translate
Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
Oct 16, 2015 2:28 AM UTC

It should be taken care in your CSS making image as background and text as center aligned for that div

Translate