Forum OpenACS Q&A: Re: Images and edit-this-page

Collapse
Posted by David Cotter on
This is strictly ad hoc of course. This is based on photo-album in 4.6.3 and HTMLArea 2.03. Here's note on  HTMLArea and ETP:

https://openacs.org/forums/message-view?message_id=115599

I think it's just these two files that were changed:

htmlarea/popups/insert_image.html
---------------------------------
var popwin = null;
function popupImage()
{
  if (! window.focus)
      return true;
  if (popwin != null) {
      popwin.close();
      popwin = null;
  }
  // I have a hardcoded URL to an instance of photo album mounted
  popwin=window.open('/img/resources/album?album_id=488', 'images', 'height=600,width=700,scrollbars=yes');
  return true;
}

...
At the bottom of the page I added the third of these buttons which calls the above popupImage() function
...

<BUTTON ID=btnOK style="left: 31.36em; top: 1.0647em; width: 7em; height: 2.2em; " type=submit tabIndex=40>OK</BUTTON>
<BUTTON ID=btnCancel style="left: 31.36em; top: 3.6504em; width: 7em; height: 2.2em; " type=reset tabIndex=45 onClick="window.close();">Cancel</BUTTON>
<BUTTON ID=btnChoose style="left: 31.36em; top: 7.000em; width: 7em; height: 2.2em; " type=submit tabIndex=50 onClick="popupImage()">Choose...</BUTTON>

needed in photo-album/www/photo.adp - I have it in a template (the template strips out all nav-bars etc so the popup looks OK
-------------------------------------------------------------
<SCRIPT defer>
function selectImage(url, title, width, height)
{
  window.opener.txtFileName.value = url;
  window.opener.txtFileName.intImageWidth  = width;
  window.opener.txtFileName.intImageHeight = height;
  window.opener.txtAltText.value          = title;

  window.close();
  return true;
}
</script>

photo-album/www/photo.adp
-------------------------
Add this "Choose" button where ever you like. I have a hardcoded URL '/img/res..' for the instance - would be easy I'm sure to generate this.
<form>
<INPUT TYPE=BUTTON onClick="selectImage('/img/resources/images/@path@/@title@', '@caption@', '@width@', '@height@')" VALUE="Choose this image"></TD>
</form>