Index: lams_common/src/java/org/lamsfoundation/lams/questions/QuestionParser.java =================================================================== diff -u -raf4e1c770ec77e97fa3d30f3bc4dbd95e5ab9f55 -r48c0f070620fb4f585ca97dad722462811e6b72e --- lams_common/src/java/org/lamsfoundation/lams/questions/QuestionParser.java (.../QuestionParser.java) (revision af4e1c770ec77e97fa3d30f3bc4dbd95e5ab9f55) +++ lams_common/src/java/org/lamsfoundation/lams/questions/QuestionParser.java (.../QuestionParser.java) (revision 48c0f070620fb4f585ca97dad722462811e6b72e) @@ -511,6 +511,31 @@ + fileName; try { FileUtils.copyFile(sourceFile, destinationFile); + + // ensure that img-responsive class is always added to img tag + int classAttributeIndex = -1; + for (int attributeIndex = 0; attributeIndex < imageAttributes + .size(); attributeIndex++) { + String attribute = imageAttributes.get(attributeIndex).strip().toLowerCase(); + if (attribute.startsWith("class")) { + classAttributeIndex = attributeIndex; + } + } + + if (classAttributeIndex == -1) { + imageAttributes.add("class=\"img-responsive\""); + } else { + String attribute = imageAttributes.get(classAttributeIndex); + if (!attribute.toLowerCase().contains("img-responsive")) { + int endQuoationMarkIndex = attribute.lastIndexOf("\""); + if (endQuoationMarkIndex > 0) { + attribute = attribute.substring(0, endQuoationMarkIndex) + + " img-responsive\""; + imageAttributes.set(classAttributeIndex, attribute); + } + } + } + replacement = ""; } catch (IOException e) {