[XFA] Extended Cover

[XFA] Extended Cover [Paid] 5.0.0 Beta 3

No permission to buy (€30.00)
I work with Nesman at TF2Maps.

The XF1.5 version of this plugin basically automatically took any attached images from the post and put them in the cover. This new version doesnt seem to do that; which is mildly annoying but we would like to be able to automatically set this up for at least the existing posts.

Example of one with attachments but no cover:

I can confirm that the cover data is stored in xf_attachment:

SQL:
select * from xf_attachment where content_id = 11399;

+---------------+---------+--------------------+------------+-------------+-----------+--------------+------------+
| attachment_id | data_id | content_type       | content_id | attach_date | temp_hash | unassociated | view_count |
+---------------+---------+--------------------+------------+-------------+-----------+--------------+------------+
| 61825         | 61856   | resource_version   | 11399      | 1504199215  |           | 0            | 56         |
| 167997        | 193756  | xfa_ec_rm_resource | 11399      | 1644407049  |           | 0            | 21         |
| 167998        | 193757  | xfa_ec_rm_resource | 11399      | 1644407062  |           | 0            | 21         |
| 167999        | 193758  | xfa_ec_rm_resource | 11399      | 1644407063  |           | 0            | 21         |
| 168000        | 193759  | xfa_ec_rm_resource | 11399      | 1644407065  |           | 0            | 21         |
+---------------+---------+--------------------+------------+-------------+-----------+--------------+------------+

I could def write some SQL to insert these into the covers; but I can't seem to find where the download post's attachments are referenced. The attachments to the main resource post does not appear to be stored in xf_rm_resource. Do you have any insights on that?
 
Update:

I managed to find the place it stores the attachment data. It appears that the first post in a resource is stored as an "update" and is always ordered first.

Code:
select resource_update_id from xf_rm_resource_update where resource_id = {resource_id} order by post_date limit 1

Then that resource update id is used in xf_attachment to show what is attached. So we can migrate these into XFA by running this query:

Code:
update xf_attachment set content_type = 'xfa_ec_rm_resource', content_id = {resource_id} where content_id = {resource_update_id} and content_type = 'resource_update'

This appears to solve our problem.

Here is the script i wrote to migrate our whole site's covers
Python:
import mysql.connector
import sys

def main():
    mydb = mysql.connector.connect(
        host="localhost",
        user="****",
        password="****",
        database="****"
    )

    cursor = mydb.cursor(buffered=True)

    query = "select resource_id from xf_rm_resource where resource_type = 'download'"

    for resource in stream_query(mydb, query):
        resource_id = resource[0]
        query = f"select resource_update_id from xf_rm_resource_update where resource_id = {resource_id} order by post_date limit 1"
        cursor.execute(query)
       
        resource_update_id = cursor.fetchone()[0]

        print(f"Updating: {resource_id}. Resource Update ID: {resource_update_id}")

        query = f"update xf_attachment set content_type = 'xfa_ec_rm_resource', content_id = {resource_id} where content_id = {resource_update_id} and content_type = 'resource_update'"
        cursor.execute(query)
       
        mydb.commit()

def stream_query(connection, query):
    c = connection.cursor(buffered=True)
    c.execute(query)
   
    while True:
        nextrows = c.fetchmany(128)
        if not nextrows:
            break
        for row in nextrows:
            yield row


if __name__ == "__main__":
    main()


I'd also like to ask if it would be possible to have this plugin automatically insert these attachments as the cover like the previous version did?
 
Last edited:
The XF1.5 version of this plugin basically automatically took any attached images from the post and put them in the cover. This new version doesnt seem to do that; which is mildly annoying but we would like to be able to automatically set this up for at least the existing posts.

Hi
Thanks for your response, but are your sure for xf1.5 version? I have rewrite this addon based on xf1.5 feature so i don’t think i have used default post attachments to put them into cover slider

Regards
 
Hi
Thanks for your response, but are your sure for xf1.5 version? I have rewrite this addon based on xf1.5 feature so i don’t think i have used default post attachments to put them into cover slider

Regards
Ah sorry, we are currently using XF 2 and this plugin.

However we were previously running 1.5 until about a month ago where we migrated to 2+
 
Top Bottom