Fork me on GitHub

[PageMaster] Show uploaded image in pubedit template  Bottom

Go to page 1 - 2 [+1]:

  • I have a pubtype which allows image uploading in a publication. When editing a publication which contains a previously uploaded image, it shows the image's filename, but not the image itself.

    How would I display the image or even a thumbnail of the image?

    My first inclination was to use the same method you'd use in a viewpub template, but that doesn't work.

    --
    Harness Technology
  • I'd suggest you insert a pndebug call into the edit template (create a custom one) and see what that shows ... the info is there so you just need to figure out the correct way of getting/building the correct path/filename.

    This should probably be a standard feature of pagemaster. I have some CSS-based popup/mouseover code that I use for this kind of stuff, if you're interested.

    Greetings
    R
  • Here is the line from the pndebug window:

    Code

    <!--[$image]-->     "a:5:{s:9:"orig_name";s:11:"survey1.jpg";s:8:"tmb_name";s:38:"3lur68hp1mfdqo36wbtrf99y5lq0pa-tmb.jpg";s:8:"pre_name";s:38:"3lur68hp1mfdqo36wbtrf99y5lq0pa-pre.jpg";s:9:"full_name";s:39:"3lur68hp1mfdqo36wbtrf99y5lq0pa-full.jpg";s:9:"file_name";s:34:"3lur68hp1mfdqo36wbtrf99y5lq0pa.jpg";}"


    I've tried all the standard tags to show that image, but to no avail.

    --
    Harness Technology
  • Try some code inside a PHP tag like this:

    Code

    $this->assign ('imagedata', unserialize($this->_tpl_vars['image']));

    That should give you the image fields in the 'imagedata' array ... then all you have to do is add the pagemaster image save path and you're done.

    Greetings
    R
  • *gasp*

    Let us not forget that using a PHP tag in a template makes you a dumbass accordingly to His Almighty Holiness of All Living Things, Mr. Voss.

    http://code.zikula.org/core/wiki/CheatSheet

    --
    Harness Technology
  • Ok, I did that and tried several little tricks to get the image to show, but to no avail. Thanks for trying. I'll just wait for Clip.

    --
    Harness Technology
  • Quote

    Let us not forget that using a PHP tag in a template makes you a dumbass accordingly to His Almighty Holiness of All Living Things, Mr. Voss.

    This is a matter of perspective. I personally am not bothered by PHP code in templates; I frequently do it for complex operations. And if it really bothers you, you could implement this as a plugin.

    Fact is that some more complex operations/logic need to be handled in PHP. There are certain things which Smarty simply does not do (for example, Smarty does not understand the $$ operator, etc.)

    Greetings
    R
  • Seems that Smarty is powerful enough to let us do this:

    Code

    {assign var='imagedata' value=$image|unserialize}

    I tested it and it worked :)

    --
    - Mateo T. -
    Mis principios... son mis fines
  • All that does is display the image array data. I tried using the standard tags like:

    Code

    <!--[$image.thumbnailUrl]-->

    But that doesn't work. What am I missing?

    --
    Harness Technology
  • The assign I posted displays something? shoult not.
    If you put a {zdebug} after it, you'll see an array on $imagedata, which means that after the unserialized assign you'll be able to use $imagedata.thumbnailUrl

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Keep in mind this is PageMaster (0.4.2) and NOT Clip, running in Zikula 1.2.4.

    I used this first:

    Code

    <!--[assign var='imagedata' value=$image|unserialize]-->

    Then tried:

    Code

    <!--[$image.thumbnailUrl]-->
    which displays the first character of the entire array, and

    Code

    <!--[$imagedata.thumbnailUrl]-->
    which displays nothing.

    However, if I simply use:

    Code

    <!--[$image]-->
    it spits out the entire array.

    --
    Harness Technology
  • Try the pndebug call after the assign line, to see what's resulting for "imagedata" icon_confused

    P/S: Even when i'm using 1.3 "terminology" the only thing that changes on my posts are the Smarty delimiters icon_wink

    --
    - Mateo T. -
    Mis principios... son mis fines
  • $imagedata returns:

    Code

    array (5)
    orig_name => "slide01.jpg"
    tmb_name => "t6m4zrlrdkrgyo9pw9ruyql5bybo42-tmb.jpg"
    pre_name => "t6m4zrlrdkrgyo9pw9ruyql5bybo42-pre.jpg"
    full_name => "t6m4zrlrdkrgyo9pw9ruyql5bybo42-full.jpg"
    file_name => "t6m4zrlrdkrgyo9pw9ruyql5bybo42.jpg"


    $image returns:

    Code

    "a:5:{s:9:"orig_name";s:11:"slide01.jpg";s:8:"tmb_name";s:38:"t6m4zrlrdkrgyo9pw9ruyql5bybo42-tmb.jpg";s:8:"pre_name";s:38:"t6m4zrlrdkrgyo9pw9ruyql5bybo42-pre.jpg";s:9:"full_name";s:39:"t6m4zrlrdkrgyo9pw9ruyql5bybo42-full.jpg";s:9:"file_name";s:34:"t6m4zrlrdkrgyo9pw9ruyql5bybo42.jpg";}"


    Yet neither of them will work when appending "thumbnailUrl", e.g.

    Code

    <!--[$imagedata.thumbnailUrl]-->
    or

    Code

    <!--[$image.thumbnailUrl]-->


    For fun, I also tried:

    Code

    <!--[$imagedata.tmb_name]-->


    In most cases, page source shows:

    Code

    <img src="" alt="thumbnail" />


    However,

    Code

    <!--[$image.thumbnailUrl]-->
    shows

    Code

    <img src="a" alt="thumbnail" />
    in source.

    --
    Harness Technology
  • Mateo, don't worry too much about it. I can live without it right now. I'd rather it was just integrated in the next version of Clip and the energy you are spending here could be put to better use working on Clip. icon_smile

    I do appreciate the effort you have put into helping me out on this. Thank you.

    --
    Harness Technology
  • thumbnailUrl is build with $modvar.uploadpath + tmb_name
    so this may work to get it:

    Code

    {assign var='thumbnailUrl' value="`$pncore.PageMaster.uploadpath`/`$imagedata.tmb_name`"}
    and use $thumbnailUrl as your IMG src.

    --
    - Mateo T. -
    Mis principios... son mis fines

Go to page 1 - 2 [+1]:

This list is based on users active over the last 60 minutes.