Radomizing Image Filenames: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==Setting image upload randomization== *In the PHP parent record class, set the image object's <code>randomize</code> property value. *Make sure that the value is not overwrit...") |
(No difference)
|
Revision as of 14:18, 12 March 2012
Setting image upload randomization
- In the PHP parent record class, set the image object's
randomizeproperty value. - Make sure that the value is not overwritten by
fill_from_input()unless it's truly intended.
class ParentContent extends db_content_class
{
function __construct()
{
parent::__construct();
$this->image = new image_upload_class($this->SECTION_ID(), $this->id->value);
$this->image->randomize->value = self::RANDOMIZE_IMAGE_FILENAME; /* <<< set randomization here (TRUE or FALSE) */
}
public function fill_from_input()
{
parent::fill_from_input();
$this->image->randomize->value = self::RANDOMIZE_IMAGE_FILENAME; /* <<< make sure the value is not overridden ever */
}
}
JavaScript/AJAX
HTML thumbnail container attributes
.gallery-tn-containerassigned "click" handler which displays edit and delete buttons.- "click" assignment:
LITTLED.Gallery.bindImageOverlayHandlers() .gallery-tn-containertemplate file:[COMMON_LIB]_templates/forms/images/image_upload_link.php
- "click" assignment:
.gallery-tn-containerattributes:data-idimage link record iddata-pidparent record iddata-tidcontent type id of the parent recorddata-opoperation, e.g. "upload", "edit", or "delete"data-randrandomization flag- Randomization attribute value is assigned by the PHP
image_upload_classpassed to the thumbnail template
- Randomization attribute value is assigned by the PHP
How the randomization flag value is passed to the AJAX script
.gallery-tn-containeronClick handler copies its attributes to the edit and delete buttons.- upload/edit button (
#edit-galltn-btn) has onClick handlerLITTLED.Gallery.selectThumbnail()- randomization flag value is retrieved from the edit button's attributes
- randomization flag value is passed to the AJAX script
Upload script
- Image upload AJAX script:
[COMMON_LIB]ajax/images/upload_image.php - parameter
ilrfdetermines randomization, e.g.:
/ajax/images/upload_image.php?ilrf=[true|false]
PHP code
image_upload_class->randomize holds value used as switch to randomize image filenames
image_upload_class->randomize set in either image_upload_class::fill_from_input() or image_upload_class::fill_inline_input()
image_upload_class inherits its save() routine from image_link_class::save($saveKeywords=false, $randomizeFilename=false)