image-select Insert a link above the image to change it and view the new one using ajax - just like facebook

  1. Requirements
  2. Demo
  3. Usage
  4. Change Log
  5. Resources

Image View Select to Change

Requirements

Yii 1.1 or above - tested on Yii 1.1.11 and above

Demo

http://yii.nefya.com

Usage

  • extract inside extensions directory
  • be sure that your extensions are imported

/config/main.php

'import'=>array(
                ...
                'application.extensions.*',
                ...
         ),
  • add this to your view:
<?php
   $this->widget('ext.imageSelect.ImageSelect',  array(
        'path'=>'path/to/current/image',
        'alt'=>'alt text',
        'uploadUrl'=>'url that accepts the uploaded image and returns the new path',
        'htmlOptions'=>array()
   ));
?>
  • In your controller you can catch the uploaded file like this sample upload action
public function actionUpload(){
    $file = CUploadedFile::getInstanceByName('file');
    // Do your business ... save on file system for example,
    // and/or do some db operations for example
    $file->saveAs('images/'.$file->getName());
    // return the new file path
    echo Yii::app()->baseUrl.'/images/'.$file->getName();
}

Change Log

  • 1.4
    • Bug fix - hide the loading div after loading the new image instead of after uploading it
  • 1.3
    • Bug fix - for multi instance inside one page
  • 1.2
    • Adding the public property $text to facilitate internationalization
  • 1.1
    • Adding loader image while loading the new one
  • 1.0
    • Initial upload

Resources

4 0
16 followers
1 951 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: Amr Bedair
Created on: Jan 20, 2013
Last updated: 11 years ago

Downloads

show all

Related Extensions