solved custom module shows double 'blank' images?

elric
@elric
10 years ago
81 posts
Hola!

So, thanks to Michael, I've got my first Aparna cloned module working. The premise is a news article. Set up with some fields:

Title
Category
Content
Image

It's working as expected, I'm able to customize the item_detail.tpl easily enough, but I'm getting these two stock images showing up on the article. See the screen shot.

I figured that they are coming from here:

*************************************************
{foreach from=$item item="v" key="k"}
{if (substr($v,0,6)) == 'image/'}
{assign var="type" value=$k|substr:0:-5}
{jrCore_module_function function="jrImage_display" module="dnNews" type=$type item_id=$item._item_id size="large" alt=$item.news_title width=false height=false class="iloutline img_scale"}

{/if}
*************************************************


If I wanted to kill that code, and place the image myself, wouldn't something like this work:

{$item.news_articleImage01}

Obviously, it isn't...

Stumped,
~E
NewsBug.JPG.jpg
NewsBug.JPG.jpg  •  71KB


updated by @elric: 08/26/14 10:00:06PM
michael
@michael
10 years ago
7,715 posts
Whenever your stumped, go look at how the other modules do it. Best place to see working examples.

The important thing is what you called the image field. If you called it news_image then thats the key to it.

{jrCore_module_function function="jrImage_display" module="jrProfile" type="profile_image" item_id=$item._profile_id size="medium" crop="square" size="40" alt=$item.profile_name title=$item.profile_name class="imgborder"}

is the full code for a profile_image.

You want a news_image (or whatever you called it.) so the simplest code to get the image up there is:

{jrCore_module_function function="jrImage_display" module="dnNews" type="news_image" item_id=1 size="40"}

Try that.
elric
@elric
10 years ago
81 posts
Thank you Michael. I didn't realize how closely Aparna cloned modules mimic other modules.

One change to the code you posted:

{jrCore_module_function function="jrImage_display" module="dnNews" type="news_image" item_id=$item._item_id size="40"}

just made the image_id pull the field dynamically.

TOO cool, man. Thanks again.
updated by @elric: 07/23/14 05:29:00PM
elric
@elric
10 years ago
81 posts
Follow question:
jrImage_display: invalid size parameter

What is the max size, and how do I change the max size? Nothing in the documentation that I can find.

:-P
elric
@elric
10 years ago
81 posts
size="large"!
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
elric:
Follow question:
jrImage_display: invalid size parameter

What is the max size, and how do I change the max size? Nothing in the documentation that I can find.

:-P

/**
 * jrImage_get_allowed_image_widths()
 * @return array Returns array of allowed image sizes
 */
function jrImage_get_allowed_image_widths(){
    $_sz = array(
        '24'       => 24,
        'xxsmall'  => 24,
        '40'       => 40,
        'xsmall'   => 40,
        '56'       => 56,
        '72'       => 72,
        'small'    => 72,
        '96'       => 96,
        'icon96'   => 96,
        '128'      => 128,
        'icon'     => 128,
        '196'      => 196,
        'medium'   => 196,
        '256'      => 256,
        'large'    => 256,
        '320'      => 320,
        'larger'   => 320,
        '384'      => 384,
        'xlarge'   => 384,
        '512'      => 512,
        'xxlarge'  => 512,
        '800'      => 800,
        'xxxlarge' => 800,
        '1280'     => 1280
    );
    return $_sz;
}



--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
michael
@michael
10 years ago
7,715 posts
Yeah nothing in the docs, but break it once and you get a nice message:

Here is a small image of me :)
https://www.jamroom.net/user/image/user_image/4/small/crop=auto

and with a non-existant image size
https://www.jamroom.net/user/image/user_image/4/super-massive/crop=auto

The second one produces the useful error:
Quote: CRI: invalid image size - must be one of: 24,xxsmall,40,xsmall,56,72,small,96,icon96,128,icon,196,medium,256,large,320,larger,384,xlarge,512,xxlarge,800,xxxlarge,1280

You'll see they line up with what SteveX has provided above.

If you do manage to find error messages that are not useful, let us know.
elric
@elric
10 years ago
81 posts
As usual, you guys rock!

Tags