Attachments: how to rebuild correct order when same images names?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Attachments: how to rebuild correct order when same images names?

Post by axe70 »

Hello guys. Sorry for my last worry about things when i posted time ago. I hope that my answers do not hurt nobody.
I will try to be smooth from now on, since i understand that often i go for my own way...
Now for the answer :)

I did an easy function that raw parse a post into WordPress.
It also now parse attachments.
So what i do is to extract attachments that belongs to the post but a problem have come out (i'm looking around to understand what/how phpBB do):
into this function, the code check for the [attachment=1]image.png[/attachment] placeholder, get the image name, search into array of attachments, then associate related attach to the placeholder.
But what about if the post contain more than one

Code: Select all

[attachment=1]image.png[/attachment] [attachment=2]image.png[/attachment]
that are two different images named the same?
I had hope to get the attach id somewhere into the post text, but i see that it is not stored, do not result into the post text.
So what i ask to myself, is how phpBB associate the right image.png to the right paceholder?
It is a sort of check that is done earlier against physical_filename (even i have not understand how at moment in case)?
Thank you!
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Attachments: how to rebuild correct order when same images names?

Post by axe70 »

May it is that ...
[attachment=1]image.png[/attachment]
belong to the image added after attach 2
[attachment=2]image.png[/attachment]
so can be checked against the attach time or id order.
Well, to rebuild things this way, should be not so easy. It require a function that check for the attachment placeholder number, then calculate times of all attachments then ... i hope what i mean is clear (and exact as possible solution).
It is what phpBB do?

P.S sorry, may this post need to be moved to Custom coding forum! :oops: move it please, sorry!
Last edited by axe70 on Sun Jan 23, 2022 8:39 pm, edited 1 time in total.
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Attachments: how to rebuild correct order when same images names?

Post by axe70 »

Please may move this post into Custom coding forum, since i wrongly started this here.
Cheers!
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Attachments: how to rebuild correct order when same images names?

Post by axe70 »

P.s
The attachment placeolder id, refer to array key as it is extracted by the attachments table.
specifically this comment made me reverse things in mind as they need to be, to know which files to display inline and correctly pairing with placeholders and so discarding from the array of remaining attachments (if there are) to show on bottom. I think this is the way phpBB manage the thing.
Cheers!

Code: Select all

	// Make sure attachments are properly ordered
	ksort($attachments);
Please may move this post into Custom coding forum, thank you
Do not take me too serious
Anyway i do not like Discourse
Post Reply

Return to “phpBB Custom Coding”