Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挕 Disable attachment pages for new ClassicPress installations. #1434

Open
KTS915 opened this issue May 7, 2024 · 6 comments 路 May be fixed by #1436
Open

馃挕 Disable attachment pages for new ClassicPress installations. #1434

KTS915 opened this issue May 7, 2024 · 6 comments 路 May be fixed by #1436

Comments

@KTS915
Copy link
Member

KTS915 commented May 7, 2024

Context

I always disable attachment pages (using Greg Schoppe's code at https://gschoppe.com/wordpress/disable-attachment-pages/).

WordPress has now caught on. See https://core.trac.wordpress.org/ticket/57913 But they messed up the implementation, so there are several changesets to get it done properly:

https://core.trac.wordpress.org/changeset/56657
https://core.trac.wordpress.org/changeset/56658
https://core.trac.wordpress.org/changeset/56711
https://core.trac.wordpress.org/changeset/57357
https://core.trac.wordpress.org/changeset/57358

Possible implementation

Presumably this can be done by using the above changesets.

Will you be able to help with the implementation?

I don't know how to implement multiple changesets. But I can help test the solution.

Unlike WP, I'd also like to see us add a toggle or checkbox somewhere, so that a site administrator can easily disable attachment pages on old sites and enable such pages on new sites. But I think that belongs in a separate PR.

@KTS915 KTS915 added type: feature request New feature or request status: needs triage This issue needs revision, splitting, or other "gardening" work labels May 7, 2024
@KTS915 KTS915 changed the title 馃挕 Disable attachment pages for new WordPress installations. 馃挕 Disable attachment pages for new ClassicPress installations. May 7, 2024
@StonehengeCreations
Copy link

There is already a "hidden" option to disable attachment pages completely, although it is not listed in the Admin.

Run this code once from your functions.php:
update_option( 'wp_attachment_pages_enabled', false );

Or go to https://www.yourdomain/wp-admin/options.php, find the wp_attachment_pages_enabled entry using the keyboard Ctrl + F and replace 1 with 0.
Then press Enter to save (or scroll all the way down for the submit button).

Once disabled all attachments will be shown in the browser using /wp-content/uploads/image.jpg automatically.
I double checked and this also works if an image has been inserted into a post/page using the Media Library Link to dropdown options Media File as well as Attachment Page.

To implement this for everyone, adding a simple checkbox in Settings > Media (file: /wp-admin/options-media.php) would most likely suffice, much like the uploads_use_yearmonth_folders option.

@KTS915
Copy link
Member Author

KTS915 commented May 12, 2024

Yes, I'm aware of all that. The point of opening this ticket is as a reminder to make things user-friendly.

PR #1436 does the bulk of the work.

To implement this for everyone, adding a simple checkbox in Settings > Media (file: /wp-admin/options-media.php) would most likely suffice, much like the uploads_use_yearmonth_folders option.

PR #1437 achieves that.

@KTS915 KTS915 removed the status: needs triage This issue needs revision, splitting, or other "gardening" work label Jun 5, 2024
@iljester
Copy link

Esiste gi脿 un'opzione "nascosta" per disabilitare completamente le pagine degli allegati, sebbene non sia elencata nell'Amministratore.

Esegui questo codice una volta dal tuo Functions.php: update_option( 'wp_attachment_pages_enabled', false );

Oppure vai su https://www.yourdomain/wp-admin/options.php, trova la wp_attachment_pages_enabledvoce utilizzando la tastiera Ctrl + Fe sostituiscila 1con 0. Quindi premere Enterper salvare (o scorrere fino al pulsante di invio).

Una volta disabilitati, tutti gli allegati verranno visualizzati automaticamente nel browser /wp-content/uploads/image.jpg. Ho ricontrollato e questo funziona anche se un'immagine 猫 stata inserita in un post/pagina utilizzando le Link toopzioni a discesa Libreria multimediale Media Filee Attachment Page.

Per implementarlo per tutti, molto probabilmente sarebbe sufficiente aggiungere una semplice casella di controllo in Settings > Media(file: ), proprio come l' opzione./wp-admin/options-media.php``uploads_use_yearmonth_folders

If this hidden option exists (which I didn't know about - I'm going to turn off attachments right away), why not make it visible on the media option page with a toggle?

@xxsimoxx
Copy link
Member

@iljester #1437 is all about adding this feature to the media options page.

@iljester
Copy link

In any case, I would like to point out that wp_attachment_pages_enabled is only available from version 6.4 of WP. I didn't find it in my installation.

https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/

@xxsimoxx
Copy link
Member

Thank you, that is backported in #1436 that's not already merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants