Kesiena Sowho Kesiena Sowho - 12 days ago 6
PHP Question

How to make Image Upload Required

How can this section of code be made compulsory/required? The code doesn't have a simple image upload field. It is from a joomla Component. I have tried specifying the attribute "required" as with the regular html upload fields, but this has not worked.

<section class="block" id="gallery">
<h2><?php echo JText::_('COM_BT_PROPERTY_GALLERY');?></h2>
<div class="center">
<div class="form-group">
<?php
if ($this->params->get('fe_upload_type', 1) == 1) {
echo $this->loadTemplate('images_flash');
} else {
echo $this->loadTemplate('images_simple');
}
?>
<?php
$params = new JRegistry();
if ($this->item->params) {
$params->loadArray($this->item->params);
}
$thumb_height = $params->get('thumb_height', $this->params->get("thumb_height", 180));
$thumb_width = $params->get('thumb_width', $this->params->get("thumb_width", 336));
if ($thumb_height > 100) {
$thumb_width = floor($thumb_width * 100 / $thumb_height);
$thumb_height = 100;
}
$thumbimgprocess = $this->params->get('thumbimgprocess', $this->params->get("thumbimgprocess", 1));
?>
<ul id="sortable">
<?php
if (is_array($this->images)) {

foreach ($this->images as $image) {
?>
<li title="Double-click to make default image"
<?php if ($image->default) echo 'class="default_image"' ?>><input class="input-default"
<?php if ($image->default) echo 'checked="checked"' ?> title="Make default"
name="default_image" type="radio" value="<?php echo $image->filename ?>" /> <img
class="img-thumb"
src="<?php echo JURI::root() . $path . '/' . $this->item->id . '/' . ($this->params->get('thumbimgprocess', 1) == -1 ? 'original' : 'thumb') . '-' . $image->filename; ?>" />
<input type="hidden" name="image_id[]" value="<?php echo $image->id ?>" /> <?php if ($image->youembed != '') {
?>

<img class="img_video" src="../components/com_bt_property/assets/img/video.png" /> <?php
}
?>
<input type="hidden" name="image_filename[]" value="<?php echo $image->filename ?>" /> <br />
<a href="javascript:void(0)" class="edit" onclick="editImage(this)"><?php echo JText::_('COM_BT_PROPERTY_EDIT');?></a> <a
href="javascript:void(0)" class="remove" onclick="removeImage(this)"><?php echo JText::_('COM_BT_PROPERTY_REMOVE');?></a>
</li>
<?php
}
?>
<input type="hidden" id="property-hidden" name="video" value="<?php echo htmlspecialchars(json_encode($this->images)); ?>" />
<?php
}
?>

</ul>
<a href="#" class="button" onclick="return removeAll()"><?php echo JText::_('COM_BT_PROPERTY_CLEAR_ALL');?></a>
</div>
</div>
<p style = "color:red;">
"Note: files must not contain any form of contact details; names, phone no, email, address, company, website and so on. As designs with such content will not be approved for posting"
</p>
</section>

Answer

I finally found the source code for the simple image upload button linked to the above code. All I had to do was specify required as usual, before the closing (>) file input tag.

Comments