SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [resolved] Need help with coding for generated link

    This is my code:
    Code:
    /**
     * Class declaration
     */
    function ZenpressPopup() {
    };
     
     /**
      * Insert an image in the text editor
      * @param imageId	Id of the image (not used yet)
      * @param imageUrl	Filename of the image
      * @param imageName	Name (title) of the image
      */
    ZenpressPopup.prototype.insertImage = function(imageId,imageUrl,imageName) {
    	form = this.getEl('options');
    	whatValue = this.getRadioValue(form.what);
    	linkValue = this.getRadioValue(form.link);
    	closeValue = this.getRadioValue(form.close);
    	wrapValue = this.getRadioValue(form.wrap);
    	sizeValue = this.getRadioValue(form.size);
    	modRewrite = form.mod_rewrite.value;
    	webPath = form.zp_web_path.value;
    	albumUrl = form.album_url.value;
    	albumName = form.album_name.value;
    	customWidth = form.custom_width.value;
    	customHeight = form.custom_height.value;
    	
    	imageHTML = "";
    	
    	if (linkValue!="none") {
    		imageHTML += '<a href="';
    		if (linkValue=="album") {
    			if (modRewrite) {
    				path = webPath+"/"+albumUrl;
    			} else {
    				path = webPath+"/index.php?album="+albumUrl;
    			}
    			imageHTML += path;
    		} else if (linkValue=="custom" && form.link_custom_url.value!="") {
    			imageHTML += form.link_custom_url.value;
    		} else {	// "image" is the default
    			if (modRewrite) {
    				path = webPath+"/"+albumUrl+"/"+imageUrl
    			} else {
    				path = webPath+"/index.php?album="+albumUrl+"&amp;image="+imageUrl
    			}
    			imageHTML += path;
    		}
    		imageHTML += '">';
    	}
    	if (whatValue=="title") {
    		imageHTML += imageName;
    	} else if (whatValue=="custom" && form.what_custom_text.value!="") {
    		imageHTML += form.what_custom_text.value;
    	} else if (whatValue=="album") {
    		imageHTML += albumName;
    	} else {	// "thumb" is the default
    		if (modRewrite && sizeValue!="custom") {
    			// ZenPhoto's mod_rewrite does not support custom size!
    			path = webPath+"/"+albumUrl+"/image/";
    			if (sizeValue!="full") {
    				path += "thumb/"
    			}
    			path += imageUrl
    		} else {
    			path = webPath+"/zen/i.php?a="+albumUrl+"&amp;i="+imageUrl;
    			if (sizeValue!="full" && sizeValue!="custom") {
    				path += "&amp;s=thumb";
    			} else if (sizeValue=="custom") {
    				path += "&amp;w="+customWidth+"&amp;h="+customHeight;
    			}
    		}
    		imageStyle = '';
    		imageClass = 'ZenPress_thumb ';
    		
    		if (wrapValue!="none") {
    			imageStyle += 'float:'+wrapValue+'; ';
    			imageClass += 'ZenPress_'+wrapValue+' ';
    		}
    		styleAttr = '';
    		if (imageStyle!='') {
    			styleAttr = 'style="'+imageStyle+'"';
    		}
    		imageHTML += '<img class="'+imageClass+'" alt="'+imageName+'" title="'+imageName+'" src="'+path+'" '+styleAttr+' />';
    	}
    	if (linkValue!="none") {
    		imageHTML += '</a>';
    	}
    
    	if(window.tinyMCE) {
    		window.opener.tinyMCE.execCommand("mceInsertContent",true,imageHTML);
    	} else {
    		this.insertAtCursor(window.opener.document.forms["post"].elements["content"],imageHTML);
    	}
    	
    	if (closeValue!="false") {
    		window.close();
    	}
    }
    The link that is generated looks like this:

    Code:
    <a href="http://www.domain.com/albums/cars/ferrari.jpg">
    How can I add rel="lightbox" to the coding?

    I tried:

    Code:
    path = webPath+"/albums/"+albumUrl+"/"+imageUrl+" rel="lightbox"
    but I get this generated:

    Code:
    <a href="http://www.domain.com/albums/cars/ferrari.jpg%20rel="lightbox.jpg"">
    but I need it to have the space for it to work.
    so it would look like

    Code:
    <a href="http://www.domain.com/albums/cars/ferrari.jpg" rel="lightbox">
    How can I do this? Sorry I have no knowledge of programming at all. Thanks in advanced.
    Last edited by onetr1p; Mar 20, 2007 at 01:56. Reason: resolved

  2. #2
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change this line:

    Code:
    ZenpressPopup.prototype.insertImage = function(imageId,imageUrl,imageName) {
    	form = this.getEl('options');
    	whatValue = this.getRadioValue(form.what);
    	linkValue = this.getRadioValue(form.link);
    	closeValue = this.getRadioValue(form.close);
    	wrapValue = this.getRadioValue(form.wrap);
    	sizeValue = this.getRadioValue(form.size);
    	modRewrite = form.mod_rewrite.value;
    	webPath = form.zp_web_path.value;
    	albumUrl = form.album_url.value;
    	albumName = form.album_name.value;
    	customWidth = form.custom_width.value;
    	customHeight = form.custom_height.value;
    	
    	imageHTML = "";
    	
    	if (linkValue!="none") {
    		imageHTML += '<a rel="lightbox" href="';


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •