Search the web
Sign In
New User? Sign Up
speckcms · Speck CMS
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Question on Image Popups in Sample App   Message List  
Reply | Forward Message #724 of 830 |
Re: [speckcms] Re: Question on Image Popups in Sample App

> Here's another interesting item: I can Login, go to the Gallery and
> Add an Image - and it appears fine in the popup. It is only existing
> images that have a problem.

Aha, found it! A bug.

The popup method of the Image content type uses the image dimensions to
determine the size of the window. If the image dimensions weren't
obtained when the image was uploaded, it tries to get obtain the
dimensions on the fly. This code to obtain the image dimensions on the
fly will pass the wrong image path to the cf_spImageInfo tag if the
application is running in a virtual directory.

To be honest, the circumstances in which the image dimensions won't have
been obtained when the image was uploaded are rare enough that this code
can be ditched. You'd have to have uploaded the images with a very old
version of Speck that didn't contain the code to obtain image dimensions
(as happened in this case) or be running CF5 without jvm integration
configured. I've attached an updated version of the Image content type
which forces the size of the popup window to 600x750 if the dimensions
weren't obtained when the image was uploaded.


Mark


Tue Jan 8, 2008 5:52 pm

markthickpaddy
Offline Offline
Send Email Send Email

<cfsetting enablecfoutputonly="Yes">
<!---
This collective work is Copyright (C) 2001-2007 by Robin Hilliard
(robin@...) and Mark Woods (mark@...),
All Rights Reserved. Individual portions may be copyright by individual
contributors, and are included in this collective
work with permission of the copyright owners.

Licensed under the Academic Free License version 2.1
--->

<cf_spType
name="Image"
description="Image"
labelRequired="no"
labelRoles="spSuper,spEdit=r"
keywordsRoles="spSuper,spEdit=r">

<cf_spProperty
name = "caption"
caption = "Caption"
type = "Text"
required = "yes"
displaySize = "70"
maxlength = "250"
finder="yes">

<cf_spProperty
name = "original"
caption = "Original"
type = "Asset"
extensions="png,gif,jpg,jpeg"
required = "yes"

maxWidth="#attributes.context.getConfigString("types","image","original_max_widt\
h")#">

<cf_spProperty
name = "originalWidth"
caption = "original width"
type = "Number"
required = "no"
displaySize = "0">

<cf_spProperty
name = "originalHeight"
caption = "original height"
type = "Number"
required = "no"
displaySize = "0">

<cf_spProperty
name = "thumbnail"
caption = "Thumbnail"
type = "Asset"
extensions="png,gif,jpg,jpeg"
required="no"
source="original"
hint="A thumbnail will be generated automatically if you leave this field
blank."

maxWidth="#attributes.context.getConfigString("types","image","thumbnail_max_wid\
th",100)#">

<cf_spProperty
name = "thumbnailWidth"
caption = "thumbnail width"
type = "Number"
required = "no"
displaySize = "0">

<cf_spProperty
name = "thumbnailHeight"
caption = "thumbnailHeight"
type = "Number"
required = "no"
displaySize = "0">


<cf_spHandler method="display">

<cfparam name="attributes.thumbnail" default="no">
<cfparam name="attributes.showCaption" default="yes">

<cfoutput>
<div class="image_display">
</cfoutput>

<cfif attributes.thumbnail>

<cfoutput><img src="#content.thumbnail#" class="image_display_thumbnail"
border="0" alt="#content.caption#" <cfif
len(trim(content.thumbnailWidth))>width="#content.thumbnailWidth#"
height="#content.thumbnailHeight#"</cfif> /></cfoutput>

<cfelse>

<cfoutput><img src="#content.original#" class="image_display_original"
border="0" alt="#content.caption#" <cfif
len(trim(content.originalWidth))>width="#content.originalWidth#"
height="#content.originalHeight#"</cfif> /></cfoutput>

</cfif>

<cfif attributes.showCaption>

<cfoutput><div
class="image_display_caption">#content.caption#</div></cfoutput>

</cfif>

<cfoutput>
</div>
</cfoutput>

</cf_spHandler>


<cf_spHandler method="picker">

<cfoutput><img src="#content.thumbnail#" border="0" alt="#content.caption#"
<cfif len(trim(content.thumbnailWidth))>width="#content.thumbnailWidth#"
height="#content.thumbnailHeight#"</cfif> /></cfoutput>

</cf_spHandler>


<cf_spHandler method="thumbnail">

<cfparam name="attributes.showCaption" default="yes">
<cfparam name="attributes.popup" default="yes">
<cfparam name="attributes.target" default="_blank">

<cfif not isDefined("request.speck.spHandlerImageThumbnailPopup")> <!--- only
write out the JS function once --->
<cfoutput><script type="text/javascript">
<!--
//<![CDATA[
function image_thumbnail_popup(id) {
var imageWindow =
window.open("/speck/types/image/popup.cfm?app=#request.speck.appName#&id=" +
id,"image_popup","menubar=no,scrollbars=yes,resizable=yes,width=10,height=10,scr\
eenX=150,screenY=100,left=150,top=100");
imageWindow.focus();
}
//]]>
//-->
</script></cfoutput>
<cfset request.speck.spHandlerImageThumbnailPopup = true>
</cfif>

<cfoutput>
<div class="image_thumbnail">
</cfoutput>

<cfif len(content.original)>

<cfif attributes.popup>

<cfoutput><a
href="/speck/types/image/popup.cfm?app=#request.speck.appName#&id=#content.spId#\
" target="#attributes.target#" title="view larger image (opens in new window)"
onclick="image_thumbnail_popup('#content.spId#');return false;"><img
src="#content.thumbnail#" class="image_thumbnail_thumbnail" border="0"
alt="#content.caption#" title="view larger image (opens in new window)" <cfif
len(trim(content.thumbnailWidth))>width="#content.thumbnailWidth#"
height="#content.thumbnailHeight#"</cfif> /></a></cfoutput>

<cfelse>

<cfoutput><a href="#content.original#" target="#attributes.target#"
title="view larger image (opens in new window)"><img src="#content.thumbnail#"
class="image_thumbnail_thumbnail" border="0" alt="#content.caption#" title="view
larger image (opens in new window)" <cfif
len(trim(content.thumbnailWidth))>width="#content.thumbnailWidth#"
height="#content.thumbnailHeight#"</cfif> /></a></cfoutput>

</cfif>

<cfelse>

<cfoutput><img src="#content.thumbnail#" class="image_thumbnail_thumbnail"
border="0" alt="#content.caption#" <cfif
len(trim(content.thumbnailWidth))>width="#content.thumbnailWidth#"
height="#content.thumbnailHeight#"</cfif> /></cfoutput>

</cfif>

<cfif attributes.showCaption>

<cfoutput><div
class="image_thumbnail_caption">#content.caption#</div></cfoutput>

</cfif>

<cfoutput>
</div>
</cfoutput>

</cf_spHandler>

<cf_spHandler method="popup">

<cfparam name="attributes.showCaption" default="yes">
<cfparam name="attributes.stylesheet" default="">

<cfif isNumeric(content.originalWidth)>

<cfset windowWidth = content.originalWidth + 50>
<cfset windowHeight = content.originalHeight + 50>

<cfif attributes.showCaption>
<cfset windowHeight = windowHeight + 50>
</cfif>

<cfif windowHeight gt 600>
<cfset windowHeight = 600>
</cfif>

<cfif windowHeight gt 750>
<cfset windowHeight = 750>
</cfif>

<cfelse>

<cfset windowWidth = 600>
<cfset windowHeight = 750>

</cfif>

<cfoutput>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>#content.caption#</title>
<script type="text/javascript">
window.resizeTo(#windowWidth#,#windowHeight#);
</script>
</cfoutput>

<cfif len(attributes.stylesheet)>

<cfoutput><link rel="stylesheet" type="text/css"
href="#attributes.stylesheet#" /></cfoutput>

</cfif>

<cfoutput>
</head>
<body style="background: ##ffffff; margin: 10px; text-align:center;">
<div class="image_popup">
<img src="#content.original#" class="image_popup_original" border="0"
alt="#content.caption#" <cfif
isNumeric(content.originalWidth)>width="#content.originalWidth#"
height="#content.originalHeight#"</cfif> />
</cfoutput>

<cfif attributes.showCaption>

<cfoutput><div class="image_popup_caption">#content.caption#</div></cfoutput>

</cfif>

<cfoutput>
</div>
</cfoutput>

<cfoutput>
</body>
</html>
</cfoutput>

</cf_spHandler>


<cf_spHandler method="contentPut">

<!--- get image dimensions, resize images if required and generate a thumbnail
if none provided --->

<cfset fs = request.speck.fs>

<!--- assets are uploaded to a temp directory before being copied to either
the secureassets or assets directory --->
<cfdirectory action="LIST"
directory="#request.speck.appInstallRoot##fs#tmp"
filter="#content.spId#*"
sort="type DESC"
name="qTmpFiles">

<cfloop query="qTmpFiles">

<cfset filePath = request.speck.appInstallRoot & fs & "tmp" & fs & name>
<cfset propertyName = listGetAt(listLast(filePath,fs),2,"_")>

<cftry>

<cf_spImageInfo file="#filePath#" r_stImageInfo="stImageInfo">

<cfset "content.#propertyName#Width" = stImageInfo.width>
<cfset "content.#propertyName#Height" = stImageInfo.height>

<cfcatch>

<cf_spDebug msg="Failed to obtain image
dimensions<br>#cfcatch.message#<br>#cfcatch.detail#">

</cfcatch>
</cftry>

</cfloop>

</cf_spHandler>

</cf_spType>

Forward
Message #724 of 830 |
Expand Messages Author Sort by Date

Hello all - I have just started using Speck CMS and I am excited about it. I got the Sydney Jabiru Demo app working with one issue - on all of the image...
tpierceint
Offline Send Email
Jan 8, 2008
3:07 pm

... That second sydneyjabiru directory shouldn't be in the path. Can you post the full details of the error, including the template in which it occurs and line...
Mark Woods
markthickpaddy
Offline Send Email
Jan 8, 2008
3:15 pm

Hello Mark, here are some more details: More error info: 11:07:46.046 - Application Exception - in C:\inetpub\webapps\speck\tags\api\content\spImageInfo.cfm :...
tpierceint
Offline Send Email
Jan 8, 2008
4:38 pm

... <!--- This collective work is Copyright (C) 2001-2007 by Robin Hilliard (robin@...) and Mark Woods (mark@...), All Rights Reserved....
Mark Woods
markthickpaddy
Offline Send Email
Jan 8, 2008
5:52 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help