The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Way to get attachment url in header?
I'm looking for a way to say....
If first attachment is an image, url ...in the headerinclude template. Any ideas? |
#2
|
||||
|
||||
I'm not sure I understand. How do you define the first attachment? Do you mean the first one used in the post? If so, you'd have to search for "[attach]" or "[attach=config]" in there and find the attachment id and then find out it's extension.
|
#3
|
||||
|
||||
I guess it would be 'if an attachment in first post is an image'
|
#4
|
||||
|
||||
That is going to require a query done right off the bat since attachments aren't looked at at the time the header is rendered. You have the threadid at that point, but that is all. So, you'd need to do a query on the thread table to get the first postid and join with the filedata (maybe attachment - I'm not looking at a database right now) table and then take a look at the extension.
|
#5
|
||||
|
||||
hrm, so it would be something like this?
SELECT attachmentid FROM attachment WHERE postid = $post[postid] ORDER BY attachmentid LIMIT 1 |
#6
|
||||
|
||||
There is no postid field in the attachment table. It would need to be something more like:
SELECT attachmentid FROM attachment WHERE contenttypeid=1 AND contentid= $post[postid] ORDER BY attachmentid LIMIT 1 (not tested at all) |
#7
|
||||
|
||||
oh okay - so then it would just be a matter of writing something to cache that in a database table so a query isn't run every time a page is loaded.
|
#8
|
||||
|
||||
I guess if I were going to do this, I would maybe add another field to the thread table. If that field is empty, then you run that query and then run another one to enter the attachmentid into the new field. That way, the two queries only get run the first time someone accesses the thread. You may need to do something for when someone edits the thread and changes attachments though.
|
#9
|
||||
|
||||
Thanks for the tips Lynne. Btw, this is the reason I'm trying to figure out how to do this:
https://vborg.vbsupport.ru/showthread.php?t=275236 It doesn't make sense that the image for facebook is static. |
#10
|
|||
|
|||
So when my php scrypt got an attachmentid (in my case it's 24561) what the path to the image would be (so the script would display the image)? I see 'filename' - 1.jpg (the original name of the picture). What is the path to it?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|