Jump to content
MakeWebGames

Add Images to your Items


Uridium

Recommended Posts

this mod will allow you to add images to your inventory items..

 

Let me get my edits together and i'll post the script

Screenshot 2023-01-23 184801.jpg

Screenshot 2023-01-23 184905.jpg

just 2 files to edit and an sql insert for the item names

 

goto your phpmyadmin go to your table and click on SQL and add this

ALTER TABLE inventory
ADD pic varchar(255);

 

then open modules/installed/inevntory/hooks/meta.php

 

and add 

new Hook("itemMetaData", function () {
    	global $db;
    	return array(
    		"id" => "pic", 
            "sort" => 11,
            "width" => 12,
            "label" => "Item Image (usually modules/installed/inventory/images/NAME OF IMAGE.jpg", 
    		"type" => "textarea",
            "rows" => 1, 
            "validate" => function ($value) { return true; }
    	);
    });

 

now open up  modules/installed/inevntory/inventory.tpl.php

 

and find on mine its line 26-27

<div class="panel-heading">
                            Information
                        </div>

 

underneath add

<div class="panel-body">
                        <center><img src="{pic}"></center>
                        </div>

and your done

 

 

 

  • Like 4
Link to comment
Share on other sites

I wouldn't say what you did was wrong by any means. I think this comes down to do you want a clean tidy database, or do you want easily maintainable files.

 

Personally I like your way due to the maintainability of the files...I know what hammer.png is every time, not always was 42.png is.

 

You could always find the middle ground and have null as a default representing {ID}.png or if there's a value you can pull that image instead. Best of both worlds 

Link to comment
Share on other sites

On 1/25/2023 at 8:12 PM, Uridium said:

2 days and no replies ???? years ago i would have had 50 - 90 replies ? Is it time to give up ?

Are you seeking validation? Replies come in their own time, and this forum definitely isn't as active as it once was. If that's all it takes for you to give up that's on you.

Link to comment
Share on other sites

8 hours ago, Veramys said:

Are you seeking validation? Replies come in their own time, and this forum definitely isn't as active as it once was. If that's all it takes for you to give up that's on you.

Good grief. Did you put on your asshole hat today? It didn't seem to me that he was looking for validation. Lots of the older members of this site do not necessarily know it's open again, under new management. And the ones that do, are doing as they've always done; submitting content ... for free, I might add. Given how active the site used to be, it's not surprising that some will wonder if it's worth posting content or not, given how few visit here anymore. That is no ones fault, by any means. And I can certainly understand why someone would question if it's worth posting any helpers or not. 

And yes ... I put on my asshole hat. There was a nicer way you could have said what you did ... or better yet, since it didn't help or contribute to his helper module you could have just said nothing at all.

And, again, yes ... I understand the irony of my own post. 

  • Like 2
Link to comment
Share on other sites

23 hours ago, Veramys said:

Are you seeking validation? Replies come in their own time, and this forum definitely isn't as active as it once was. If that's all it takes for you to give up that's on you.

Id never give up I was however saying back in the days when MWG was Criminal Existence as soon as youd post there were about 10 replies within the hour.. Just miss all the people that were here from them days..

Link to comment
Share on other sites

  • 7 months later...

Nice modification, i just add a:

width="150" height="100" 

because if put image different sizes this makes every item same size image

<div class="panel-body">
                        <center><img src="{pic}" width="150" height="100"></center>

</div>

  • Like 1
Link to comment
Share on other sites

On 9/28/2023 at 10:13 PM, kendril said:

Nice modification, i just add a:

width="150" height="100" 

because if put image different sizes this makes every item same size image

<div class="panel-body">
                        <center><img src="{pic}" width="150" height="100"></center>

</div>

Quick tip for ya; if you need to dynamically resize an image on output, but want to keep its aspect ratio, avoid using the deprecated height and width attributes.
Instead, a little CSS goes a long way.
 

.panel-image {
  max-width: 150px;
  max-height: 100px;
}
<img src="{pic}" alt="A basic image title" class="panel-image">

Alternatively, you can inline the styling
 

<img src="{pic}" alt="A basic title" style="max-width: 150px; max-height: 100px;">

 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...