Site logo

Archived topic

attachment page linking

9 replies · Started by Matthew on March 18, 2019

Viewing posts 1–10 of 10

hi Tom,

There's something causing the disallowing of an attachment page to be the child of another attachment page.

I tested this a fair bit earlier on and WordPress does permit parent/child relationship for attachments (and not just images attached to regular pages and posts). Had it working in Enfold but have left that theme for other reasons. It also works in the default WordPress themes i.e. TwentyFourteen.

To demonstrate what I mean simply there are two random test images with filenames of:

1) atmosphere-processors-plain-1
2) possessed-girl-exorcism-2

#2 is attached or uploaded to #1 i.e. it's child

However when I click 'View' for the child image in WP Media Library I get redirected to the parent page and the permalink is:

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/#main/possessed-girl-exorcism-2/#main

For comparison, when I click View in TwentyFourteen the correct child page is shown and the permalink is:

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-2/

This linking is an essential thing for me as I have built image variations that connect to each other, so I'm hoping this can be able to be remedied.

Not sure if it's the #main anchor interfering, got a feeling its something else, but could be wrong.

thanks again,

Hi there,

#2 is attached or uploaded to #1 i.e. it’s child

How are you doing this? Can you show me a screenshot?

Does this method work in the TwentyNineteen theme?

Hi Tom, thanks for the followup,

Images:
#1) atmosphere-processors-plain-1
#2) possessed-girl-exorcism-1

So I insert an image directly from the attachment editing screen using a custom field.
Image #2 is inserted while in edit screen of #1.
Screenshot 1

Then check the image in the media library and it stays 'Unattached' because the upload in the previous step was inside the attachment edit screen i.e. not inside a regular page. If I click 'Attach' here it only provides option to attach to a page or post so I go to next step.
Screenshot 2

So go to the attachment editing screen this time for #2 image the one I just uploaded to #1. Scroll to Parent Info currently on 0.
Screenshot 3

I enter a unique number for Parent Info, which is 3715 (#1 images unique number) and click Update. It makes #1 image the parent
Screenshot 4

Back at media library the 'Uploaded to' column now shows the #1 image for its parent
Screenshot 5

On the front end the inserted image on #1 attachment page is set to link to the #2 attachment page. But this link now does not work
Screenshot 6

On the front end on #2 attachment page as mentioned before, the code that connects back to the parent also does not function. I also just tried this on TwentyNineteen and it does work for that theme correctly i.e. this code:

the_post_navigation(
array(
'prev_text' => _x( '<span class="meta-nav">Published in</span><br><span class="post-title">%title</span>', 'Parent post link', 'twentynineteen' ),
)
;

Plugins used:
Advanced Custom Fields (Screenshot 1); the only way to upload/insert media on an attachment page.
Media Library Assistant: I think this adds the change parent field (Screenshot 3, Screenshot 4) but the standard WP Media Library (Screenshot 5) shows the result under 'Uploaded to' column

Thanks,

Hmm, ok, I'm not quite understanding 100% yet.

Is the issue that you can't access the child attachment? Or is it that the post navigation (the_post_navigation() function) isn't working? I've never worked with child and parent attachments, so the concept is new to me.

Yes that's right. When I attach one image to another image the child attachment can't be accessed.

After attaching them I go to the Media Library and click 'View' on the child image. But it goes to the parent and the URL is:

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/#main/possessed-girl-exorcism-01/#main

i.e. it can't get to 'possessed-girl-exorcism-01'

Whereas in TwentyNineteen I correctly get the child and the URL is:

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/

And this is what Media Library Assistant does when I click 'View' on the child image after attaching them:

first it correctly goes to the child image looking for it...

http://www.imjexa.com/?attachment_id=3459

but it can't find it so it then redirects to the parent...

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/

Whereas in TwentyNineteen after looking for it then manages to find it...

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/

Media Library Assistant is virtually identically the media library again but it has some beefed up features.

If I manually enter or paste the URL
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/

it goes to the correct child page and the function the_post_navigation in the child attachment works properly to bring user back to the parent. But the linking setup in the code does not. Looking at those URL's it could be just the #main ID or anchor interfering? How can I suppress the ID to test it?

thanks,

Realised I forgot to provide password for 'Hide my Site' plugin. Did this block entry to those screen captures? I just sent it to you thru your Contact form in case.

Very strange, I can't imagine what GP would be doing differently than a core theme when it comes to something like this.

Does Media Library Assistant have active support? If it does, any chance we can check with them on what would possibly cause this? Any sort of hint would help, as right now I'm not sure where to look.

Looking at those URL’s it could be just the #main ID or anchor interfering? How can I suppress the ID to test it?

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/#main/possessed-girl-exorcism-01/#main

Vs other themes:

http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/

This is what it's doing differently. Could you at least tell me what this is that's coming from the template code? It look like the cause

I removed these from attachment.php (based on single.php and content-single.php) without any difference:

id="main" <?php generate_do_element_classes( 'main' ); ?>

do_action( 'generate_before_main_content' );

I have also asked with the media library assistant.

thanks,

I was just about to give up and get someone to check it out. Then this. Boom!

Awesome! :)

This archived topic is closed to new replies.